PDA

View Full Version : QStyle: draw QLineEdit like box



ickby
8th December 2010, 19:42
Hello together!

i am trying to draw a sunken border frame with white background, something looking like QLineEdit. This is the code i came up with after quite some experimenting and qt-source digging:



QStyleOptionFrameV2 option;
option.initFrom(this);
option.state |= QStyle::State_Sunken;
option.rect.setRect(x,y,width,height);
QApplication::style()->drawPrimitive(QStyle::PE_PanelLineEdit, &option, painter);
QApplication::style()->drawPrimitive(QStyle::PE_FrameLineEdit, &option, painter);


Problem is that the white panels edges are not rounded (i am using KDE oxygen style) like the frame and are visible outside the frame at the edges. Just a few pixels, but that looks ugly! Any idea whats wrong with this code?

And another problem that came up in this respekt: how can i draw the focused and mouse_over states? It seems they are not drawn by PE_FrameLineEdit itself and PE_FrameFocusRect primitive does nothing for me.

Thanks for any help,
Stefan