pos() is not position of cursor in the screen?
and how can I find center of poshbutton?
pos() is not position of cursor in the screen?
and how can I find center of poshbutton?
Well, I assume that "this" in your code is a QWidget derived class, which makes pos() most likely this function: QWidget::pos().
Of course if "this" is a class of your own and you have implemented a pos() function that returns the cursor on screen, than that is what it will return.
In that case you need to make sure to map it to the button's coordinate system.
button->rect().center(), but why do you need that?
Cheers,
_
I use this line of code and it emits signal
QTest::mouseClick(this->m_button, Qt::LeftButton,0,m_button->rect().center(),-1);
Clicking the center is the default behavior if you don't specify a position, so you could just call
Qt Code:
QTest::mouseClick(this->m_button, Qt::LeftButton);To copy to clipboard, switch view to plain text mode
Cheers,
_
NIK-VAJ (18th February 2016)
I have another question. which function give me position of a widget in main window?
pos() gives you the position relative to its parent.
The parent's mapToGlobal() can map that to a global positon, the main window's mapFromGlobal can turn that into a position within main window.
Cheers,
_
thank you very much![]()
Bookmarks