[PyKDE] Problem with QToolButtons in QWidget

Willi Richert w.richert at gmx.net
Fri Jul 12 15:23:00 BST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I try to get the LnF of the left Outlook Pane. I tried QToolBar and other 
things, and ended up having a docked WIdget containing QToolButtons (I know 
it is not the intended use of QToolButton, but comes closest to the wanted 
LnF).

Suprisingly, text and pixmap are never shown both on the buttons. If setText() 
comes last, the text is only shown if I do not invoke b.setUsesTextLabel(1). 
If setPixmap() is called last, the pixmap is shown. Any hints?

Here the code (without the kxpm):
============================================================
def main():
    a=QApplication(sys.argv)
    w=QMainWindow()
    
    appDock = QDockWindow()
    appDock.setResizeEnabled(0)
    appDock.setCloseMode(QDockWindow.Always)
    appDock.setFixedExtentWidth(100)
    w.addDockWindow(appDock, QDockWindow.DockLeft)	
    appbar = QWidget(appDock)
    appDock.setWidget(appbar)

    text = "test"
    b = QToolButton(appbar)
    b.setToggleButton(1)
    b.setBackgroundOrigin(QToolButton.WidgetOrigin)
    b_font = QFont(b.font())
    b.setFont(b_font)
    b.setFocusPolicy(QToolButton.NoFocus)

    b.setUsesBigPixmap(1) # curious behaviour
    b.setUsesTextLabel(1) # curious behaviour

    b.setPixmap(QPixmap(kxpm)) # curious behaviour
    b.setText(text) # curious behaviour
    b.setAutoRaise(1)
    appbar.appBarLayout = QGridLayout(appbar, 10, 1, 5,5)
    appbar.appBarLayout.addWidget(b,0,0)
    appbar.b=b

    a.setMainWidget(w)
    w.resize(400,500)
    w.show()
    a.exec_loop()
    sys.exit(0)


if __name__ == '__main__':
    main()
============================================================

Thanks all.
- -- 
Vieles ist einfach, der Rest zweifach.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9Lth4Clnsru/vnVgRAv55AKDEqJJBvNeBWpJrQ5m+kM//7ha2rgCgtkQR
b9Ygfvu/5iWcxu6RYnFHb4E=
=QhF3
-----END PGP SIGNATURE-----




More information about the PyQt mailing list