PyQt QWidget仅显示标题栏

2024-09-26 17:47:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在打开应用程序中的多个文件。对于大文件,它需要几秒钟才能打开,因此我显示了一个QWidget,它的状态是打开的文件。在

主应用程序将一个信号传递给qwidget,标题栏得到更新。在

我使用setWindowFlags(Qt.WindowTitleHint)来删除最小化/最大化按钮。在

  1. 这样做对吗?在

{1美元^

  1. QWidget是否可能只显示标题栏?在

Screenshot showing the window title without buttons

#This is the method for reading files in the main class
#Some other method passes filenames to this method
def readfiles(self,filenames):
    fopenstins=FileOpenStatusWidget()
    fopenstins.show()
    for i in range(len(filenames)): # Read files one by one
        self.emit(SIGNAL('fopenstsig'),i+1,len(filenames)) 
        #### More Code for reading files#####

class FileOpenStatusWidget(QtGui.QWidget):
    def __init__(self):
        super(FileOpenStatusWidget, self).__init__()
        self.connect(main,SIGNAL('fopenstsig'),self.qwrtt)
        self.layout = QtGui.QVBoxLayout()
        self.status=QtGui.QLabel()
        self.layout.addWidget(self.status) # This does not work -- Window remains blank 
        self.setWindowFlags(Qt.WindowTitleHint)
        self.setLayout(self.layout)


     def qwrtt(self,openedfiles,totalfiles):
         self.status.setText('Opening File '+str(openedfiles)+'/'+str(totalfiles))
         if openedfiles==totalfiles:
            self.hide()
         else:
            self.setWindowTitle(self.status.text())

Tags: 文件self应用程序fordefstatusfilesmethod
1条回答
网友
1楼 · 发布于 2024-09-26 17:47:03

使用标志的组合:Qt.CustomizeWindowHint | Qt.WindowTitleHint。在

窗口图标和关闭按钮由默认添加的Qt.WindowSystemMenuHint控制。Qt.CustomizeWindowHint禁用所有默认提示。在

相关问题 更多 >

    热门问题