0

我正在使用带有tabbuttons和qmaindwindow的qt在mac中设计一个设置窗口。

当单击 qmainwindow 工具栏中的相应选项卡按钮时,我想显示一个从顶部滑动的选项卡窗口。与 mac 系统首选项或 vlc 首选项滑动窗口操作相同。

希望有人知道实现它的方向吗?

提前致谢

滑动动作不起作用。事件我为 qmainwindow 中的每个选项卡尝试了 QDialog。

from PyQt4 import QtGui
from PyQt4 import QtCore

class Ui_windo(QtGui.QMainWindow):

    def __init__(self,parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        self.setObjectName("windo")
        self.resize(400, 300)
        self.toolbuttonGroup = QtGui.QButtonGroup()
        self.toolbuttonGroup.setObjectName("toolbuttonGroup")
        self.toolbuttonGroup.setExclusive(True)
        self.button0 = QtGui.QToolButton()
        self.button1 = QtGui.QToolButton()
        self.button2 = QtGui.QToolButton()
        self.tabbutton(self.button0, 'button0')
        self.tabbutton(self.button1, 'button1')
        self.tabbutton(self.button2, 'button2')

        _toolBar = self.addToolBar('test')
        _toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        _toolBar.addWidget(self.button0)
        _toolBar.addWidget(self.button1)
        _toolBar.addWidget(self.button2)
        self.setUnifiedTitleAndToolBarOnMac(True);

        QtCore.QObject.connect(self.button0, QtCore.SIGNAL('clicked()'), self.dialog0)
        QtCore.QObject.connect(self.button1, QtCore.SIGNAL('clicked()'), self.dialog1)
        QtCore.QObject.connect(self.button2, QtCore.SIGNAL('clicked()'), self.dialog2)

    def dialog0(self):
        self._dialog0 = QtGui.QDialog()
        self._button0=QtGui.QPushButton(self._dialog0)
        self._button0.setText('Main dialog 0')
        self._dialog0.setModal(True)
        self.setCentralWidget(self._dialog0)

    def dialog1(self):
        self._dialog1 = QtGui.QDialog()
        self._button1=QtGui.QPushButton(self._dialog1)
        self._button1.setText('I m from dialog1')
        self._dialog1.setModal(True)
        self.setCentralWidget(self._dialog1)

    def dialog2(self):
        self._dialog2 = QtGui.QDialog()
        self._button2=QtGui.QPushButton(self._dialog2)
        self._button2.setText('I m from dialog2')
        self._dialog2.setModal(True)
        self.setCentralWidget(self._dialog2)

    def tabbutton(self, tabButton, text):
        self.toolbuttonGroup.addButton(tabButton)
        tabButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        tabButton.setText(text)
        tabButton.setObjectName(text)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        tabButton.setIcon(icon)
        tabButton.setCheckable(True)

if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    ui = Ui_windo()
    ui.show()
    sys.exit(app.exec_())
4

1 回答 1

0

使用 QDialog 并将父设置为必须“向下滑动”的窗口。它会“自动”完成

于 2012-05-25T10:26:45.587 回答