PDA

View Full Version : Search box?



sdfisher
18th March 2007, 22:57
Mac OS X has a "search field" control. Is there a way to do something like this in Qt, both on Mac OS X and Windows? (I don't care about a pixel-by-pixel match, but the icon inside the edit looks great.)

Apple's description of this search field is here (http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_6.html#//apple_ref/doc/uid/TP30000359-TPXREF210).

wysota
19th March 2007, 00:13
Yes, it's possible. Use a QLineEdit and a stylesheet that changes the padding and sets a background image to the padded rectangle. Alternatively place QToolButtons (or QLabel if you don't want the icons clickable) and a QLineEdit in a horizontal layout with 0 spacing.

A crude example attached. Obtained with the following stylesheet:
padding-right: 20px;
padding-left: 5px;
background: url(/usr/share/icons/crystalsvg/16x16/actions/exit.png);
background-position: right;
background-repeat: no-repeat;

border: 1px solid black;
border-radius: 10px;

sdfisher
19th March 2007, 18:37
Awesome. The one thing I needed to change was to put the whole style sheet in a QLineEdit{ } element. Otherwise, the right click menu showed the icon on each menu item.