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
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
Could you rephrase and clearly state what you have done so far? How does your status bar show the message etc.
J-P Nurmi
Have you tried adding a label widget? And writing to that instead of the main statusbar label?
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
Could you show us the mouseMoveEvent() implementation? Are you sure you don't have multiple status bars? This works fine for me:
Qt Code:
// main.cpp #include <QtGui> Q_OBJECT public: setMouseTracking(true); } signals: void message(const QString& str); protected: emit message(tr("(%1, %2)").arg(event->x()).arg(event->y())); } }; int main(int argc, char* argv[]) { QMainWindow window; window.setCentralWidget(new Widget); window.show(); return app.exec(); } #include "main.moc"To copy to clipboard, switch view to plain text mode
J-P Nurmi
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:
{ QString str; QString str1; QString str2; str.clear(); str1.clear(); str2.clear(); lastX=event->pos().x(); lastY=event->pos().y(); str=str1+str2; statusBar1->setLayoutDirection(Qt::RightToLeft); statusBar1->showMessage(str); } { setFocusPolicy (Qt::StrongFocus ); setFocus(Qt::OtherFocusReason); setMouseTracking(true); label1-> setFont(font); label1->setGeometry(10,20,300,10); statusBar1-> setFont(font); // statusBar1->insertPermanentWidget(0,label1); // window->setStatusBar(statusBar1); }To copy to clipboard, switch view to plain text mode
Last edited by jpn; 3rd February 2009 at 16:04. Reason: fixed [code] tags
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?
i tried as, i put in slot as
Qlabel label1();
statusbar()->addpermanentwidget(label1);
but it is not working. could u plz clarify this onestatusbar()->label1->setText(QString);
Hi, you have to store the pointer to label1 since QStatusBar provides no possibilities to access inserted widgets.
Ginsengelf
Bookmarks