Question

I am learning PyQt and wonder if one can create custom/owner draw control like one show in the figure below:

alt text http://lh5.ggpht.com/_5XDoB4MglkY/SpoT51SXR1I/AAAAAAAAFcU/ZXjzmhRyDVA/s400/SearchBox.png

The search box has magnifier icon on its right border. Is this kind of thing possible with PyQt? Thanks!

Was it helpful?

Solution

If you only need to show an icon, an easy way is to use style-sheets:

lineedit = QtGui.QLineEdit()    
lineedit.setStyleSheet("""QLineEdit {
     background-image: url(:/images/magnifier.png);
     background-repeat: no-repeat;
     background-position: right;
     background-clip: padding;
     padding-right: 16px;
}""")

OTHER TIPS

Antas Aasma - good anser! m3rLinEz Maybe its worth packing all buttons and text labels into one widget. In constructor of that widget connect all buttons. Expose only necessary signals and slots. Just to reduce code you write (and possibly increase reuse of this widget).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top