hi friends,
how to get the globalPos() of a particular widget in a qt application withoout using mouseEvent() ....
hi friends,
how to get the globalPos() of a particular widget in a qt application withoout using mouseEvent() ....
use QCursor:: pos().
PS. sorry, f*****g smiles.![]()
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
...orQt Code:
To copy to clipboard, switch view to plain text mode
wagmare (26th March 2009)
thanks for reply ... i am sorry to mention this ... i am developing a qapp where
i want to check communication status every 5 sec .. if the communication fails i want to show a balloon message telling "communication failed" over a pushButton ...
so i need the globalPos of the pushButton but i cant use QMouseEvent or cursor ...
on creating the pushButton i want to send this position to the qtooltip constuctor .. so that i can set the tooltip to that position ....
as Lykurg said you can use this
Qt Code:
To copy to clipboard, switch view to plain text mode
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Qt Code:
To copy to clipboard, switch view to plain text mode
As QWidget::rect().topLeft() is allways QPoint(0, 0) which one is faster/better? Yes I know it's a stupid question, because this optimization won't make your app faster, but academically I'm interested in...
Yepp, and after a look through assistant I realized that topLeft etc gives no reference back, so in the specific case QPoint(x,y) is faster/better.
thank you .. i will follow the same ..
Qt Code:
static int dynamite = 2; QString test = "The communication failed due to heavy rain networ all jammed \n and the enemy is attacking ... no no "; qreal x = value.x(); qreal y = value.y(); if(dynamite == 2){ printf("it is visible in this area \n"); } dynamite = 1; }else if(dynamite == 1){ dynamite = 2; printf("it is visible in this area \n"); } }To copy to clipboard, switch view to plain text mode
i tried
value = diagnosButton->mapToGlobal(QPoint(0,0));
instead of value = diagnosButton->mapToGlobal(diagnosButton->rect().topLeft());
and its not working ... only widget->rect().topLeft()); is working perfectly in this code ...
when u use this:
Qt Code:
To copy to clipboard, switch view to plain text mode
how far from the button does the tooltip show or it doesnt show at all?
thanks for reply ..
the assistant tells
"Translates the widget coordinate pos to global screen coordinates. For example, mapToGlobal(QPoint(0,0)) would give the global coordinates of the top-left pixel of the widget."
so i thought by default it will give the global pos of the button ...so i try to show the tooltip just above the coordinates ...
no, i mean when u use QPoint(0,0), what does it do..does it show the tooltip at a wrong place or it doesnt show anything?
Bookmarks