Results 1 to 7 of 7

Thread: Using QTimer and mouseMoveEvent

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Using QTimer and mouseMoveEvent

    I would be inclined to make the QLabels look after their own highlighting when the mouse is over them.

    Qt Code:
    1. #include <QApplication>
    2. #include <QWidget>
    3. #include <QVBoxLayout>
    4. #include <QLabel>
    5. #include <QPixmap>
    6. #include <QGraphicsDropShadowEffect>
    7.  
    8. class Label: public QLabel
    9. {
    10. Q_OBJECT
    11. public:
    12. Label(QWidget *p = 0): QLabel(p)
    13. {
    14. QPixmap pixmap(200, 200);
    15. pixmap.fill(QColor("mediumseagreen"));
    16. setPixmap(pixmap);
    17. setFrameStyle(QFrame::Box);
    18.  
    19. QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
    20. shadow->setBlurRadius(10);
    21. shadow->setColor(QColor("orchid"));
    22. setGraphicsEffect(shadow);
    23. }
    24. protected:
    25. void enterEvent(QEvent *event)
    26. {
    27. QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
    28. shadow->setBlurRadius(10);
    29. shadow->setColor(QColor("lightsalmon"));
    30. setGraphicsEffect(shadow);
    31. }
    32. void leaveEvent(QEvent *event)
    33. {
    34. QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
    35. shadow->setBlurRadius(10);
    36. shadow->setColor(QColor("orchid"));
    37. setGraphicsEffect(shadow);
    38. }
    39. };
    40.  
    41. class Widget: public QWidget
    42. {
    43. Q_OBJECT
    44. public:
    45. Widget(QWidget *p = 0): QWidget(p)
    46. {
    47. QVBoxLayout *layout = new QVBoxLayout(this);
    48. layout->addWidget(new Label);
    49. layout->addWidget(new Label);
    50. }
    51. };
    52.  
    53. int main(int argc, char **argv)
    54. {
    55. QApplication app(argc, argv);
    56. Widget w;
    57. w.show();
    58. return app.exec();
    59. }
    60. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

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

    LaTj (3rd December 2013)

Similar Threads

  1. Replies: 1
    Last Post: 25th October 2012, 19:47
  2. Replies: 15
    Last Post: 4th August 2012, 19:11
  3. mouseMoveEvent
    By weixj2003ld in forum Qt Programming
    Replies: 1
    Last Post: 3rd November 2009, 09:04
  4. mouseMoveEvent receiving zero's
    By JohnTh in forum Newbie
    Replies: 2
    Last Post: 11th September 2009, 17:31
  5. About the mouseMoveEvent()
    By bingoking in forum Qt Programming
    Replies: 3
    Last Post: 26th September 2008, 11:56

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.