Results 1 to 14 of 14

Thread: Make different regions of QLabel act differently, like an image map

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Join Date
    Jan 2008
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Make different regions of QLabel act differently, like an image map

    I had a similar scenario with a row of PushButtons that I wanted to change color as the mouse was over them. They were implemented flat in QTDesigner with mouseTracking set true. Text in a QLabel also changed depending on the PushButton under the cursor.

    Qt Code:
    1. void Clone::mouseMoveEvent( QMouseEvent *event)
    2. {
    3. int X = event->x();
    4. int Y = event->y();
    5.  
    6. if( X > 0 && X < 160)
    7. {
    8. if( Y > 0 && Y < 80)
    9. {
    10. TWButton->setPalette( QColor( 255,255,255,255));
    11. textLabel->setText( twString);
    12. }
    13. else
    14. TWButton->setPalette( QColor( 0,170,255,255));
    15.  
    16. etc.
    To copy to clipboard, switch view to plain text mode 

    I'm sure you could accomplish the same thing with a group of QLabels merged together so they would look like a single object until changed by the cursor.

  2. The following user says thank you to GTBuilder for this useful post:

    codeslicer (17th February 2008)

Similar Threads

  1. Set the image at the center in QLabel?
    By vishal.chauhan in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2007, 14:07
  2. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57

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
  •  
Qt is a trademark of The Qt Company.