[Solved] QLabel is not moving Fast as mouse pointer moves of the mouse.



  • I want to move a QLabel from different thread. How Could I achieve this .



  • Hi, QWidget and its sub-classes can not be used in work-threads.



  • NIHAO 1+1=2,
    But I have used Its working .But Not moving fast as Mouse Cursor Moves.



  • Yes, in some simple cases, it may works. But you should know that :

    From Qt documentation http://qt-project.org/doc/qt-5.1/qtcore/threads-qobject.html

    bq. the GUI classes, notably QWidget and all its subclasses, are not reentrant. They can only be used from the main thread

    BTW, if it doesn't move as fast as mouse moves, perhaps you main thread is busy on some other things.


  • Moderators

    moving a QWidget form antoher thread may only be an issue when you don't use a QueuedConnection. If you do so it's safe to do it.

    Even if you do all the work in your main thread your widget will never move as fast as the mouse moves. This is due to the event based architecture.



  • Actually my idea was making a label as a mouse pointer by adding an pixmap of mouse pointer and moving it according to the mouse pointer.
    I have achieved some movement but whenever i move my mouse fast then label jumps.
    So I should assume that There is no way of moving a label as fast as mouse moves in Qt.


  • Moderators

    then use "QCursor's constructor":http://qt-project.org/doc/qt-4.8/qcursor.html#QCursor-4 for that. In this way it will work as intended and you won't have lags.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.