Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Return QPointF one cicle before connect(class, SIGNAL(QPointF...

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

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by
    #1

    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 ....

    bkt

    FlotisableF 1 Reply Last reply
    0
    • gfxxG gfxx

      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 ....

      FlotisableF Offline
      FlotisableF Offline
      Flotisable
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • gfxxG Offline
        gfxxG Offline
        gfxx
        wrote on last edited by
        #3

        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

        bkt

        FlotisableF 1 Reply Last reply
        0
        • gfxxG gfxx

          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

          FlotisableF Offline
          FlotisableF Offline
          Flotisable
          wrote on last edited by
          #4

          @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.

          gfxxG 1 Reply Last reply
          1
          • FlotisableF Flotisable

            @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.

            gfxxG Offline
            gfxxG Offline
            gfxx
            wrote on last edited by gfxx
            #5

            @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

            bkt

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved