Results 1 to 8 of 8

Thread: Set a ToolButton Hovered

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    PUNE (INDIA)
    Posts
    49
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Set a ToolButton Hovered

    Hello Sir ,
    the Stylesheets are applied to the buttons already & its working fine with mouse events.
    My requirement is to change the state i.e. from unselected button to the hovered button without moving mouse over it.
    The button should be in hovered state .

    In other words , just need to shift focus from one button to another when we press a arrow keys , like we set in other languages like setTabOrder() in HTML , setTabIndex()
    Thanks & Regards ,

    Vajindar Laddad .
    Trainee Developer.
    (INDIA).
    91+9325014248

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Set a ToolButton Hovered

    Quote Originally Posted by vajindarladdad View Post
    In other words , just need to shift focus from one button to another
    Setting focus is different from hovering. Did you try what I suggested ?

  3. #3
    Join Date
    Dec 2008
    Location
    PUNE (INDIA)
    Posts
    49
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Set a ToolButton Hovered

    Hi All & YogeshGokul,
    I tried what you all suggested but it is still not working .
    I have attached a trial project in which i have created the object of QHoverEvent & invoking the event.
    Please... Please let me know where i am going wrong.

    This is the function where i want to make the QToolButton Hovered.
    Qt Code:
    1. void Widget::keyPressEvent(QKeyEvent *event)
    2. {
    3. QPoint newPos(toolButton->pos().x()+5,toolButton->pos().y()+10);
    4. QPoint oldPos(QCursor::pos());
    5.  
    6. qDebug("ToolButton Position %d %d",newPos.x(),newPos.y());
    7. qDebug("Cursor Position %d %d",oldPos.x(),oldPos.y());
    8.  
    9. QHoverEvent *hoverEvent = new QHoverEvent(QEvent::HoverEnter,newPos,oldPos);
    10. QApplication::postEvent(toolButton,hoverEvent);
    11.  
    12. qDebug("In Widget::keyPressEvent");
    13. QWidget::keyPressEvent(event);
    14. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files
    Thanks & Regards ,

    Vajindar Laddad .
    Trainee Developer.
    (INDIA).
    91+9325014248

Similar Threads

  1. Toolbutton odd sizes
    By andytork in forum Qt Programming
    Replies: 0
    Last Post: 21st January 2009, 06:25
  2. how exclusive toolbutton in toolbar
    By irmakci in forum Qt Programming
    Replies: 2
    Last Post: 30th July 2008, 22:33
  3. Dockwidget and Toolbutton
    By sandeepvl in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2008, 07:23

Tags for this Thread

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.