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. When does an emit start the method to service it?
Forum Updated to NodeBB v4.3 + New Features

When does an emit start the method to service it?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 5 Posters 2.8k 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.
  • S Offline
    S Offline
    st2000
    wrote on last edited by
    #1

    Hi...

    I have a state machine (switch statement) that is controlled by pressing Qt buttons. When a button in pressed it executes the method containing the state machine. Once in a while there may be reason to skip a state because there is only one option (i.e. there isn't a reason to ask the user as the answer is obvious). So I was trying to skip over these "silly" questions by simulating a button press by using the emit command. I thought button presses and emits would lock each other out. That is, I assumed I could not call my state machine recursively. But I have been seeing some funny stuff. So now I am wondering if my assumption is true.

    If I am managing to recursively enter my state machine, how would I get around this problem? Set a flag and use an external timer to run the emit? Sounds very Rube Goldberg-ish.

    -thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      Unless you are using queued connections, an emit immediately executes all of the slots connected to that particular signal.

      Without seeing a sample of your code, it's hard to determine what's happening. What, exactly, are you emitting?

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wagner.reck
        wrote on last edited by
        #3

        did you tried to call the slot directly instead of find the button object and 'force' a signal just to call the slot?

        'I will not buy this record, it's scratch'

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          Sounds like your program is actually in a different state in that case. That would mean you have to actually document that state (and its transitions) in your code.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            Slots can be executed immideatly or queued, depending on the connection and the thread appearance.

            By default, connections are auto connections, which means, if the objects live in the same thread, they are direct connections. direct connections are like direct function calls. If the objects live in different threads or you specify QueuedConnection in the connect statement, the signal is queued to the event queue and executed in the next queue iteration (message Loop).

            To specify a connect type, use the following connect statement:

            @
            connect (sender, signal, receiver, method, Qt::QueuedConnection);
            @

            "see QObject::connect":http://doc.qt.nokia.com/4.7/qobject.html#connect

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            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