pyqt4 - Python PyQt/PySide QMdiArea subwindows scroll not working in TabbedView -
i have setup simple example using pyqt designer.see below. have mdiarea in in adding form subwindow. made form bit lengthier mainwindow see if scroll-bar appears child sub-window.
problem: if set mdiarea setviewmode(qtgui.qmdiarea.tabbedview)
scrollbars stop working , disappear. howeevr if dont use tabbedview, scrollbars work fine. can tell me whats wrong ? need tabbedview of mdiarea working scrollbars.
i using python 2.7,pyqt 4.8.4/pyside 1.2.1 on win7.
python sample code: comment line self.mdiarea.setviewmode see example working.
import sys pyqt4 import qtcore, qtgui class ui_mainwindow(object): def setupui(self, mainwindow): mainwindow.setobjectname( "mainwindow" ) mainwindow.resize(500, 400) self.centralwidget = qtgui.qwidget(mainwindow) self.centralwidget.setobjectname( "centralwidget" ) self.verticallayout = qtgui.qvboxlayout(self.centralwidget) self.verticallayout.setobjectname( "verticallayout" ) self.mdiarea = qtgui.qmdiarea(self.centralwidget) self.mdiarea.setverticalscrollbarpolicy(qtcore.qt.scrollbarasneeded) self.mdiarea.sethorizontalscrollbarpolicy(qtcore.qt.scrollbarasneeded) self.mdiarea.setactivationorder(qtgui.qmdiarea.creationorder) self.mdiarea.setviewmode(qtgui.qmdiarea.tabbedview) self.mdiarea.settabsclosable(true) self.mdiarea.settabsmovable(true) self.mdiarea.setobjectname( "mdiarea" ) self.verticallayout.addwidget(self.mdiarea) mainwindow.setcentralwidget(self.centralwidget) self.menubar = qtgui.qmenubar(mainwindow) self.menubar.setgeometry(qtcore.qrect(0, 0, 508, 21)) self.menubar.setobjectname( "menubar" ) self.menuadd = qtgui.qmenu(self.menubar) self.menuadd.setobjectname( "menuadd" ) mainwindow.setmenubar(self.menubar) self.statusbar = qtgui.qstatusbar(mainwindow) self.statusbar.setobjectname( "statusbar" ) mainwindow.setstatusbar(self.statusbar) self.menubar.addaction(self.menuadd.menuaction()) self.retranslateui(mainwindow) qtcore.qmetaobject.connectslotsbyname(mainwindow) def retranslateui(self, mainwindow): mainwindow.setwindowtitle( "mainwindow" ) self.menuadd.settitle( "&add form" ) class ui_form(object): def setupui(self, form): form.setobjectname( ("form")) form.resize(400, 800) self.gridlayout = qtgui.qgridlayout(form) self.gridlayout.setobjectname( ("gridlayout")) self.plaintextedit = qtgui.qplaintextedit(form) self.plaintextedit.setminimumsize(qtcore.qsize(0, 731)) self.plaintextedit.setobjectname( ("plaintextedit")) self.gridlayout.addwidget(self.plaintextedit, 0, 0, 1, 1) self.buttonbox = qtgui.qdialogbuttonbox(form) self.buttonbox.setstandardbuttons(qtgui.qdialogbuttonbox.cancel|qtgui.qdialogbuttonbox.ok) self.buttonbox.setobjectname( ("buttonbox")) self.gridlayout.addwidget(self.buttonbox, 1, 0, 1, 1) self.retranslateui(form) qtcore.qmetaobject.connectslotsbyname(form) def retranslateui(self, form): form.setwindowtitle( "lengthy subwindow" ) self.plaintextedit.setplaintext( "lengthy form" ) class myapp(qtgui.qmainwindow): def __init__(self, parent=none): super(myapp, self).__init__(parent) self.ui = ui_mainwindow() self.ui.setupui(self) def add_subwindow(self): widget = qtgui.qwidget() self.subwin_abq = ui_form() self.subwin_abq.setupui(widget) self.subwindow = qtgui.qmdisubwindow(self.ui.mdiarea) widget.setparent(self.subwindow) self.subwindow.setwidget(widget) self.subwindow.setwindowtitle("testing") self.ui.mdiarea.addsubwindow(self.subwindow) widget.show() self.subwindow.show() self.subwindow.widget().show() if __name__ == "__main__": app = qtgui.qapplication(sys.argv) window = myapp() window.show() window.add_subwindow() sys.exit(app.exec_())
just wanted code in op - looking simple mdi example in pyqt, , yours helped lot! don't have answer, can note far: have python 2.7,pyqt 4.8.3, , commenting settabsclosable
, settabsmovable
line, example show this:
i downloaded designer-qt4
, looked there qmdiarea
, there seems nothing called tabbedview
. found this:
qtwidgets 5.0: qmdiarea class | documentation | qt project
enum viewmode { subwindowview, tabbedview }
enum describes view mode of area; i.e. how sub-windows displayed.
subwindowview 0 display sub-windows window frames (default).
tabbedview 1 display sub-windows tabs in tab bar.
documentmode: property holds whether tab bar set document mode in tabbed view mode.
the way read this: either display subwindows in mdi fashion (so can larger window, scrollbars) or subwindows become tabs in tabbed view - , there size of subwindow doesn't matter anymore, expands take available tabbed area. also, in code, self.ui.mdiarea.documentmode()
returns false
in both cases.
i added snippet @ end of myapp.add_subwindow()
:
sp = self.subwindow.sizepolicy() print sp.__dict__ #print dir(sp) attr in dir(sp): try: print "obj.%s = %s" % (attr, getattr(sp, attr)) except: pass
this dumps interesting data (i'm not sure if object properties, though):
obj.buttonbox = 2 obj.checkbox = 4 obj.combobox = 8 obj.controltype = <class 'pyqt4.qtgui.controltype'> obj.controltypes = <class 'pyqt4.qtgui.controltypes'> obj.defaulttype = 1 obj.expandflag = 2 obj.expanding = 7 obj.fixed = 0 obj.frame = 16 ...
... these don't change in running tabbed vs. mdi mode.
so, maybe intended behavior? if so, mean you'd have find "lone" tab display widget; add programmatically several qmdiareas; hide of them default 1 @ start; , bind click on respective tabs show "their" qmdiarea , hide others (but needless say, haven't tested it).
Comments
Post a Comment