Results 1 to 3 of 3

Thread: About the custom status bar

  1. #1
    Join Date
    Oct 2012
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Post About the custom status bar

    Now I need a custom status bar, and I try to overload mouseMoveEvent(QMouseEvent *event), code is as follows:
    qDebug()<<QCursor:: pos().x()<<QCursor:: pos().y();
    QWidget *widget = QApplication::widgetAt(event->pos());
    if(widget == ui->pushButton)
    ui->statusbar->setToolTip(tr("button"));
    (I set mouse with tracking before this code, by setMouseTracking(true))
    When I move mouse over the pushbutton, and no display on the status bar, I'm very sad, what's happened??

    And I try to another method to solve the custom status bar, with eventFilter(QObject *obj, QEvent *event), code is as follows:
    if(obj == ui->pushButton)
    {
    if(event->type() == QEvent::Enter)
    {
    ui->statusbar->setToolTip(tr("over pushbutton"));
    }
    else if(event->type() == QEvent::Leave)
    ui->statusbar->setToolTip(tr(""));
    return true;
    }
    else
    {
    ui->statusbar->setToolTip(tr(""));
    return QWidget::eventFilter(obj,event);
    }
    With this method, prompts("over pushbutton") in the status bar, but the pushbutton isn't display in the window.
    Last edited by Hughen; 28th March 2013 at 14:18. Reason: 拼写更正

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: About the custom status bar

    Qt Code:
    1. QWidget *widget = QApplication::widgetAt(event->pos());
    To copy to clipboard, switch view to plain text mode 
    This will not work. QApplication::widgetAt() expects a global screen position and event->pos() gives position of the mouse cursor, relative to the widget that received the event


    With this method, prompts("over pushbutton") in the status bar, but the pushbutton isn't display in the window.
    You code should look like this
    Qt Code:
    1. if(obj == ui->pushButton)
    2. {
    3. if(event->type() == QEvent::Enter)
    4. {
    5. ui->statusbar->setToolTip(tr("over pushbutton"));
    6. }
    7. else if(event->type() == QEvent::Leave)
    8. ui->statusbar->setToolTip(tr(""));
    9. }
    10. else
    11. {
    12. ui->statusbar->setToolTip(tr(""));
    13. }
    14. return QWidget::eventFilter(obj,event);
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    Hughen (29th March 2013)

  4. #3
    Join Date
    Oct 2012
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: About the custom status bar

    I want to know how to create a custom status bar?
    I can't find out a way to solve this pragram.

Similar Threads

  1. Replies: 3
    Last Post: 8th July 2010, 07:41
  2. Custom Model? Custom View? Custom Delegate?
    By Doug Broadwell in forum Newbie
    Replies: 4
    Last Post: 11th February 2010, 20:23
  3. Status Bar
    By waynew in forum Newbie
    Replies: 3
    Last Post: 21st November 2009, 09:07
  4. Status Bar in a SUB WINDOW.
    By Cutey in forum Qt Programming
    Replies: 3
    Last Post: 23rd July 2008, 07:42
  5. need help with the status bar
    By filmfreak in forum Qt Programming
    Replies: 2
    Last Post: 15th February 2006, 08:34

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.