PySide6 QWidget更改窗口标题

PySide6.QtWidgets.QWidget类的成员函数setWindowTitle()用于为窗口更改标题;

示例代码

import sys
from PySide6 import QtCore, QtWidgets, QtGui

class MyWidget(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()

        self.button = QtWidgets.QPushButton("修改标题")

        self.layout = QtWidgets.QVBoxLayout(self)
        self.layout.addWidget(self.button)

        self.button.clicked.connect(self.setTitle)

    @QtCore.Slot()
    def setTitle(self):
        self.setWindowTitle("perfcode.com")#修改标题

if __name__ == "__main__":
    app = QtWidgets.QApplication([])
    widget = MyWidget()
    widget.resize(300, 200)

    widget.setWindowTitle("hello world")#修改标题

    widget.show()
    sys.exit(app.exec())

原创内容,如需转载,请注明出处;

本文地址: https://www.perfcode.com/p/pyside6-qtwidgets-qwidget-setwindowtitle.html

分类: 计算机技术
推荐阅读:
Python 获取网卡的MAC地址 获取网卡MAC地址可以使用Python标准库中的uuid模块;uuid模块提供了getnode()函数,用于获取机器的MAC地址。这个函数返回一个整数值,表示机器的48位MAC地址,其中高16位可能包含厂商信息。
在C语言中如何表示无穷大 在C语言中,可以使用预定义的常量INFINITY来表示正无穷大。
Rust:cannot assign twice to immutable variable `x`错误解决方法 在rust语言中,变量默认情况下是不允许被改变的,当你试图修改一个不可变变量时,将造成 error[E0384]: cannot assign twice to immutable variable `x` 这样的错误;
gin+Nginx获取真实的客户端IP 当使用Nginx为Golang gin程序做反向代理(端口转发)或负载均衡时,gin得到的客户端IP为127.0.0.1,这是由于Nginx没有正确配置导致;
一条Linux命令让你看起来很忙还很酷 在Linux系统下,如果你想让你的终端看起来很忙,或者想在某人面前装酷,那么你一定需要这条命令来实现:
xxxx is not in the sudoers file. This incident will be reported. 解决方法 使用sudo命令时出现xxxx is not in the sudoers file. This incident will be reported. 这里的xxxx是你的用户名;出现这个提示通常是用户名没有写入到sudoers文件中;