Results 1 to 2 of 2

Thread: UI Idea please

  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default UI Idea please

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: UI Idea please

    Subclass QLabel, reimplement its paint event and:
    Quote Originally Posted by munna
    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
    ...use QWidget::enterEvent() and QWidget::leaveEvent()...

    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.
    ...use QWidget::focusInEvent() and QWidget::focusOutEvent() with alpha blending active to draw the shadow...

    You may get a problem with layouts, as either the label won't allow you to draw the shadow if it's not inside its bounds, or the layout will move all the content which is directly below the label even lower if you decide to resize the label to fit the shadow.

Similar Threads

  1. I need idea for code desing
    By The Storm in forum Qt Programming
    Replies: 6
    Last Post: 11th August 2008, 02:18
  2. QWidget Settings advanced idea
    By MarkoSan in forum Qt Programming
    Replies: 9
    Last Post: 27th March 2008, 10:41
  3. skins idea
    By CopyrightPhilly in forum General Discussion
    Replies: 1
    Last Post: 11th November 2007, 16:16
  4. Grab idea from Amarok
    By jiveaxe in forum Qt Programming
    Replies: 8
    Last Post: 6th November 2007, 19:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.