Results 1 to 8 of 8

Thread: statusbar

  1. #1
    Join Date
    Jan 2009
    Posts
    33
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Post statusbar

    hi,
    i have created my own statusbar.in which i am displaying (x,y) coordinates as mouse moves. but as mouse moves it is over writing without clear message.
    can any one help me for this problem

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: statusbar

    Could you rephrase and clearly state what you have done so far? How does your status bar show the message etc.
    J-P Nurmi

  3. #3
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: statusbar

    Have you tried adding a label widget? And writing to that instead of the main statusbar label?
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  4. #4
    Join Date
    Jan 2009
    Posts
    33
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: statusbar

    hi,
    in my mainwindow i have glwidget. in glwidget constructor i define my own statusbar(i.e statusbar1). i have written program for mousemoveevent() of glwidget. it give (x,y) coordinates. in mousemoveevent() i have written as

    statusBar1->showMessage(str);

    here str contains (x,y) coordinates.

    now problem is first, when mouse point to one point it displays clearly in statusbar. but as mouse moves ,instead of clear previous status, it is displaying (overwriting) upon previous value. so i am not able to see clear values

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: statusbar

    Could you show us the mouseMoveEvent() implementation? Are you sure you don't have multiple status bars? This works fine for me:
    Qt Code:
    1. // main.cpp
    2. #include <QtGui>
    3.  
    4. class Widget : public QWidget {
    5. Q_OBJECT
    6. public:
    7. Widget(QWidget* parent = 0) : QWidget(parent) {
    8. setMouseTracking(true);
    9. }
    10.  
    11. signals:
    12. void message(const QString& str);
    13.  
    14. protected:
    15. void mouseMoveEvent(QMouseEvent* event) {
    16. emit message(tr("(%1, %2)").arg(event->x()).arg(event->y()));
    17. }
    18. };
    19.  
    20. int main(int argc, char* argv[])
    21. {
    22. QApplication app(argc, argv);
    23. QMainWindow window;
    24. window.setCentralWidget(new Widget);
    25. app.connect(window.centralWidget(), SIGNAL(message(QString)), window.statusBar(), SLOT(showMessage(QString)));
    26. window.show();
    27. return app.exec();
    28. }
    29.  
    30. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  6. #6
    Join Date
    Jan 2009
    Posts
    33
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: statusbar

    hi,
    below is my mouse move event and GLWidget is central widget of my mainwindow.here i have one more problem i have setgeometry() for GLWidget as setGeometry(QRect(0,40,1015,515)). now if i setgeometry for statusbar below this i am not able to observe statusbar.if i setgeometry inside glwidget geometry it is overlapping my painting and has black color statusbar and white characters.


    Qt Code:
    1. void GLWidget::mouseMoveEvent(QMouseEvent *event)
    2. {
    3. QString str;
    4. QString str1;
    5. QString str2;
    6. str.clear();
    7. str1.clear();
    8. str2.clear();
    9.  
    10.  
    11. lastX=event->pos().x();
    12. lastY=event->pos().y();
    13. str1 = QString("x: %1 , ").arg(lastx, 0, 'E', 3);
    14. str2 = QString(" y: %1").arg(lasty, 0, 'E', 3);
    15. str=str1+str2;
    16. statusBar1->setLayoutDirection(Qt::RightToLeft);
    17. statusBar1->showMessage(str);
    18.  
    19.  
    20. }
    21.  
    22. GLWidget::GLWidget(QWidget *parent):QGLWidget(parent)
    23.  
    24. {
    25. setFocusPolicy (Qt::StrongFocus );
    26. setFocus(Qt::OtherFocusReason);
    27. setMouseTracking(true);
    28. statusBar1=new QStatusBar(this);
    29. statusBar1->setGeometry(QRect(0,475,1015,55));
    30. label1=new QLabel(statusBar1);
    31.  
    32. QFont font("Helvetica", 12, QFont::Bold);
    33. label1-> setFont(font);
    34. label1-> setPalette(QPalette(QColor(225,22,45),QColor(23,12,34)));
    35. label1->setGeometry(10,20,300,10);
    36.  
    37. statusBar1->setPalette(QPalette(QColor(225,22,45),QColor(23,12,34)));
    38. statusBar1-> setFont(font);
    39.  
    40.  
    41.  
    42. // statusBar1->insertPermanentWidget(0,label1);
    43. // window->setStatusBar(statusBar1);
    44.  
    45. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 3rd February 2009 at 15:04. Reason: fixed [code] tags

  7. #7
    Join Date
    Jan 2009
    Posts
    33
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: statusbar

    hi,
    thank you for u r reply. now i am able to dispaly in mainwindow statusbar.
    i have one more doubt.
    suppose if i add Qlabel widget to the statusbar() then how can i dispaly same values in that?


    Qlabel label1();
    statusbar()->addpermanentwidget(label1);
    i tried as, i put in slot as

    statusbar()->label1->setText(QString);
    but it is not working. could u plz clarify this one

  8. #8
    Join Date
    Jul 2008
    Posts
    434
    Thanks
    9
    Thanked 57 Times in 55 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: statusbar

    Hi, you have to store the pointer to label1 since QStatusBar provides no possibilities to access inserted widgets.

    Ginsengelf

Similar Threads

  1. QDialog StatusBar
    By skuda in forum Qt Programming
    Replies: 5
    Last Post: 16th July 2010, 01:07
  2. statusbar problem
    By bhogasena in forum Qt Programming
    Replies: 2
    Last Post: 3rd February 2009, 05:09
  3. Setting statusBar ignoring action tooltips
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 11th October 2007, 13:07
  4. forecolor of statusbar
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2007, 07:55
  5. statusBar() message color change
    By mclark in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 23:20

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.