Return QPointF one cicle before connect(class, SIGNAL(QPointF...



  • hi ... in these repo my example code ...

    my repo , from class draggablerectitem I use a return function ... If I call these from mainwindows, it return the data, but the data is returned with 1 app cycle delay .... i click 1 time and move rect ....and obtain not the current data but previous .... if I use emit/connet slot/system the data return immediately ... why these??

    regards
    giorgio

    .... if use emit signal I bring the data immediately ....



  • @gfxx
    sorry, I can't understand well from your description.
    can you point out where the code get error?



  • no error code .... example of debug:

    first mouse release:

    mystupid pos .....    10,20  /****    qDebug() << "mystupid pos ....." << m_p;   in my class this is private var .... I send it trought emit and using function return */
    mainwindow on copysender:... 0,0   /****     qDebug() << "mainwindow on copysender:...." << dItem->lastPoint();  on mainwindows  call my returning function when mause release */
    mainwindow on dItem:... 10,20 /****     qDebug() << "mainwindow on dItem:...." << pp;  on mainwindows  use these slot connected to dItem signal */
    
    

    second mause release:

    mystupid pos .....    120,20  /****    qDebug() << "mystupid pos ....." << m_p;   in my class this is private var .... I send it trought emit and using function return */
    mainwindow on copysender:... 10,20   /****     qDebug() << "mainwindow on copysender:...." << dItem->lastPoint();  on mainwindows  call my returning function when mause release */
    mainwindow on dItem:... 120,20 /****     qDebug() << "mainwindow on dItem:...." << pp;  on mainwindows  use these slot connected to dItem signal */
    
    

    delay of one cicle of work ....

    regards
    Giorgio



  • @gfxx
    I have test your code and found that the reason of the delay may be related to the event propagation.

    since you are using the Graphics View Framework, the event will propagate from view to scene, and then item.

    so when your mouse release, the copysender signal in scene's mouseReleaseEvent will be emitted first. when this happen, the dItem haven't update it's position since that is finished in item's mouseReleaseEvent. and then the event propagate to item's mouseReleaseEvent, it update dItem's position and emit emitpoint signal.

    that's why you get the 1 cycle delay.



  • @Flotisable Tanks .... these is really a possibility ... I was afraid not to have managed well m_p in return function ... or I wrote it bad .... they are the first experience with the writings of classes and objects and their mechanism for me it is not so obvious .... sometimes I'm afraid of making big mistakes ..... thanks for your opinion I help.

    Any how, I make a quite good subclass OBject parent .... so I use signal/slot mechanism instead of return void .... I these way can Have mypoint when I ask it.

    If you have some other suggest about these , feel free to write about. It 'a good thing for my learning.

    regards
    giorgio


Log in to reply
 

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