Results 1 to 4 of 4

Thread: Highligh Button on mouse move.

  1. #1
    Join Date
    Oct 2010
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Highligh Button on mouse move.

    Hi All,

    I have developed an application and succesfully ported it to my Blackfin board with touchscreen support. In the frames developed, I have some pushbuttons which I need to highlight on mouse movement over it. I have implemented both mouseMoveEvent and enterEvent functions. Now the problem is

    1) When I move across the buttons, only mouseMoveEvent function is getting executed. I dont find the enterEvent function getting called. (Is that Ok if I do the implementation in mouseMoveEvent function)?.
    2) I implemented the below code in the mouseMoveEvent function with which the highlight was not happening.

    Qt Code:
    1. button->setAutoFillBackground(true);
    2. button->setStyle(new QPlastiqueStyle);
    3. QPalette palette2 = myclassbutton->palette();
    4. palette2.setColor(QPalette::Button, Qt::green);
    5. palette2.setColor(QPalette::Light, Qt::yellow);
    6. button->setPalette(palette2);
    To copy to clipboard, switch view to plain text mode 

    I tried different combinations with the QPalette but none of them worked for me. Also please tell me how to know over which button the current mouse movement has happened as the class for which I have overriden the mouse event functions have many buttons.

    Please help me regarding this.

    Regards,
    Siva
    Last edited by wysota; 20th October 2010 at 15:03.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Highligh Button on mouse move.

    Did you set the Qt::WA_Hover attribute ?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    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: Highligh Button on mouse move.

    You will get enter and leave events only if mouse tracking is enabled. For hover behaviour (provided you set the hover attribute as already suggested) you will only get additional paint events and you need to react there. And certainly not by changing the button's palette but rather by modifying the way the style is called. Better yet subclass the style and do a proper implementation there based on the object state you receive with each call.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Highligh Button on mouse move.

    2) I implemented the below code in the mouseMoveEvent function with which the highlight was not happening.
    You paint only in paintEvent... not in any other function.

Similar Threads

  1. Display hint when move mouse to a button
    By baobui in forum Newbie
    Replies: 2
    Last Post: 20th October 2010, 21:14
  2. How to move the mouse ?
    By shad0w in forum Newbie
    Replies: 3
    Last Post: 2nd November 2008, 13:55
  3. Move mouse over object
    By ToddAtWSU in forum Qt Programming
    Replies: 17
    Last Post: 3rd October 2007, 15:53
  4. Mouse Move Event
    By merry in forum Newbie
    Replies: 5
    Last Post: 3rd June 2007, 06:26
  5. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 05:34

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.