Results 1 to 3 of 3

Thread: statusbar problem

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

    Post statusbar problem

    hi,
    i have QGLwidget inside the mainwindow. for mouseMoveEvent( )in GLwidget i would like to dispaly my object coordinates in statusbar of Mainwindow().
    but inside mouseMoveEvent() of QGLwidget() we can't access statusbar() of mainwindow. so inside mouseMoveEvent() i call one function which is declared in class which is derived from mainwindow.this function is successfully receving values correctly. but it not showing .
    could anyone help me what is the reason. here i am sending snap shot
    Qt Code:
    1. GLWidget:public QGLidget;
    2. window:public QMainwindow()
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void GLWidget::mouseMoveEvent(QMouseEvent *event)
    2. {
    3. ------------
    4. ------------
    5. longitude=wx;
    6. latitude=wy;
    7. window->Display(longitude,latitude);
    8.  
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. bool Window::Display(double a,double b)
    2. {
    3. double longitude=a;
    4. double latitude=b;
    5. QString str1 = QString("Lon: %1 , ").arg(longitude, 0, 'E', 3);
    6.  
    7.  
    8. QString str2 = QString(" Lat: %1").arg(latitude, 0, 'E', 3);
    9. QString str=str1+str2;
    10. statusBar()->setLayoutDirection(Qt::RightToLeft);
    11. statusBar()->showMessage(str);
    12.  
    13. //QMessageBox::information(this, "Test",str);
    14.  
    15. return true;
    16.  
    17. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 2nd February 2009 at 14:49. Reason: reformatted to look better

  2. #2
    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: statusbar problem

    I think you should use signals and slots instead of such a construct. Simply emit a signal with coordinates to show in mousePressEvent and connect to that signal with a slot in your main window where you have access to the status bar.

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

    Default Re: statusbar problem

    hi,
    even though i used signal and slot mechanism,its't not working.
    i put breakpoint at emit dispaly(longitude,latitude). but it is not connecting to the slot

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  2. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  3. statusBar() message color change
    By mclark in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 23:20
  4. problem with statusbar
    By philipp1 in forum Qt Programming
    Replies: 1
    Last Post: 13th October 2006, 07:12
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.