c++ - Qt QCursor::setPos() does nothing -


i've created minimal class demonstrate problem. i'm trying set cursor position, shows no effect. in example class try center cursor widget. here class:

class testwidget : public qwidget {     q_object public:     testwidget(); protected:     virtual void mousemoveevent(qmouseevent* event); }; 

and here implementation:

testwidget::testwidget() {     setminimumsize(800,600);     show(); }  void testwidget::mousemoveevent(qmouseevent *event) {     qpoint before(mapfromglobal(qcursor::pos()));     qpoint center = maptoglobal(qpoint(width()/2,height()/2));     qcursor::setpos(center);     qdebug()<<"before:"<<before<<"after:"<<mapfromglobal(qcursor::pos()); } 

when moving mouse cursor while pressing mouse button following output (exmaple):

before: qpoint(754,48) after: qpoint(400,300)

this means before called qcursor::setpos(center) cursor @ position 754;48 in top-right corner of widget. after set cursor-position qcursor::setposition(center) cursor should @ center of widget, not, cursor stays in top-right corner. , further confusion, qcursor::pos() returns center of widget, though cursor not @ center.

any hints appreciated.

thank time...

@leiaz right, i've been working in virtual machine. when running program on host system (which ubuntu) works expected. thank help.

it works in vm now, after i've disabled mouse integration.

thanks all.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -