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. How Connect Two Timed Methods in sequence
Forum Updated to NodeBB v4.3 + New Features

How Connect Two Timed Methods in sequence

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 806 Views 2 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.
  • W Offline
    W Offline
    wwolff
    wrote on last edited by
    #1

    Hi!
    I have a simple doubt here , and i dont know if it´s possible with Qt:

    I have a simple OpelGL Window where i use a Render method to update the rendering using a timer as below:

        connect(this, SIGNAL(widthChanged (int)), this, SLOT(resizeGl()));
        connect(this, SIGNAL(heightChanged(int)), this, SLOT(resizeGl()));
    
        timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(RenderScene()));
        timer->start(0);
    

    My doubt is:
    It´s possible i connect another method like "UpdateScene" slot that be executed only after RenderScene finish it´s job?

    Any help will be much appreciated becouse i´m having syncronization issues between the rendering being performed in the screen and the data being updated on the aplication, since the GPU´s are rendering in threads.

    Kind Regards.

    1 Reply Last reply
    0
    • Paul ColbyP Offline
      Paul ColbyP Offline
      Paul Colby
      wrote on last edited by
      #2

      Hi @wwolff

      I might be missing the point of what you're asking, but as slots are just regular functions, you can always call one from the other, eg:

      void MyClass::RenderScene() {
          // do whatever RenderScene does.
          UpdateScene(); // invoke the UpdateScene slot directly.
      }
      

      If you're bothered by the added coupling, you can emit your own signal as a go-between, eg:

      void MyClass::MyClas(...) {
          connect(this, SIGNAL(sceneRendered()), this, SLOT(UpdateScene()));
          // the rest of your sample code from above here...
      }
      
      void MyClass::RenderScene() {
          // do whatever RenderScene does.
          emit sceneRendered();
      }
      

      Since you've specifically mentioned using threads, you probably want to use the signal/slot separation, because that allows you to use Qt's queued connections (or other connection types as appropriate) if signalling from one thread, to another's slot... have a read of Signals and Slots Across Threads.

      Cheers.

      1 Reply Last reply
      2
      • W Offline
        W Offline
        wwolff
        wrote on last edited by
        #3

        Thanks so much!
        This is exactly what´s i´m looking for (A way to fire up a signal to inform that my UpdateScene Method need be executed).

        I will try it!

        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