[PyQt] setLayout for a QDockWidget
TP
paratribulations at free.fr
Thu Jun 25 17:56:57 BST 2009
Hi,
Try the small script below. I cannot manage to do setLayout for a
QDockWidget: QDockWidget.setWidget() works correctly, but not
QDockwidget.setLayout(), I obtain the following message:
QWidget::setLayout: Attempting to set QLayout "" on QDockWidget "", which
already has a layout
So, with some googling, I found:
http://lists.trolltech.com/pipermail/qt-interest/2008-December/000524.html
http://www.qtcentre.org/forum/f-newbie-4/t-changing-layout-21394.html
It seems that there is a default layout inside a QDockWidget when it is
created. How to delete this default layout in PyQt, and then set as new
layout "vboxlayout" with the spin box in the following code?
Thanks a lot,
Julien
############
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
app = QApplication( sys.argv )
spin = QSpinBox()
vboxlayout = QVBoxLayout( )
vboxlayout.addWidget( spin )
qmainwin = QMainWindow()
qdock = QDockWidget( )
existing_layout = qdock.layout()
print existing_layout
# how to delete the existing layout??
qdock.setLayout( vboxlayout )
qmainwin.addDockWidget( Qt.TopDockWidgetArea, qdock )
qmainwin.show()
app.exec_()
--
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\
9&1+,\'Z4(55l4('])"
"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)
More information about the PyQt
mailing list