Hi,
I have lots of QLabel and QLineEdit in my application. Normally the background of both QLabel and QLineEdit is white and text color is black. Also the backgound of the widget on which they are(the parent) is also white. To make it look rich I have to do the following:
1. When mouse over on QLabel : The background changes to gray, the text color changes to white and also the label is rounded on left. It basically looks like:
_________
(_________| on mouse over
2. When the line edit is focused, a shadow should appear at the bottom. The problem with this is that this shadow should not hide the text which is below this line edit.
To achieve this I do the following.
1. When mouse is on the label, change the palette and then tell the parent about the bounds of this label. Parent calls repaint and in the paintEvent of the parent I draw the curve part so that we get the overall look. Is this is good way to do ? Is there a better way to achieve this. Notice I do not use any pixmap to achieve this. Is all drawing.
2. This is more complicated. Let's see if I can explain.
I first place all the line edits in its position and hide them all. Call the paintEvent of the parent and draw the text of all the line edits in the position where they are hidden. When user clicks anywhere I see if he has clicked on any of the line edits.
If he has clikced on any of them, then I show that particular line edit with a shadow which is drawn on the parent. Since the all the rest of the text is drawn after the shadow is drawn, everything looks ok.
I don't know if there is a better way to achieve this but I think its a dirty way.
Can some one please tell if there is a better way to achieve this ?
Note: The method I use does the trick and is also very fast, but the thing is that both the label and line edit is now coupled with its parent. Also, I see that a nice shadow comes for popupmenu. Can someone please tell how this shadow is drawn ?
Thanks a lot for your time and ideas.
Thanks once again
Bookmarks