PDA

View Full Version : statusbar problem



bhogasena
2nd February 2009, 14:03
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


GLWidget:public QGLidget;
window:public QMainwindow()


void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
------------
------------
longitude=wx;
latitude=wy;
window->Display(longitude,latitude);


}



bool Window::Display(double a,double b)
{
double longitude=a;
double latitude=b;
QString str1 = QString("Lon: %1 , ").arg(longitude, 0, 'E', 3);


QString str2 = QString(" Lat: %1").arg(latitude, 0, 'E', 3);
QString str=str1+str2;
statusBar()->setLayoutDirection(Qt::RightToLeft);
statusBar()->showMessage(str);

//QMessageBox::information(this, "Test",str);

return true;

}

wysota
2nd February 2009, 14:51
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.

bhogasena
3rd February 2009, 05:09
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