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 to automatically emit a signal

How to automatically emit a signal

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 1.7k Views 3 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.
  • R Offline
    R Offline
    rocklionmba
    wrote on last edited by
    #1

    Hello,
    I was wondering if there was a way to automatically emit a signal. So instead of, lets say, you clicking a button to calculate something, that instead once you finish editing it, it automatically runs the signal.
    Is there a possible way to do this?

    Chris KawaC 1 Reply Last reply
    0
    • R rocklionmba

      Hello,
      I was wondering if there was a way to automatically emit a signal. So instead of, lets say, you clicking a button to calculate something, that instead once you finish editing it, it automatically runs the signal.
      Is there a possible way to do this?

      Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @rocklionmba said in How to automatically emit a signal:

      that instead once you finish editing it, it automatically runs the signal.

      What is "it"? Finish editing what? Can you give a specific example of what you're trying to do?
      Signals are just regular c++ functions so whatever you can do with regular c++ functions you can do with signals.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rocklionmba
        wrote on last edited by
        #3

        So I have a list of items that all need to be filled out ( Unit of measure, number of coats, material type, quantity, paint type) before any calculations can be done. What I want to do is to have it where once all of them are filled out, it automatically sends the signal to the slots where it calculates it.

        1 Reply Last reply
        0
        • Chris KawaC Online
          Chris KawaC Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @rocklionmba said in How to automatically emit a signal:

          it automatically sends the signal to the slots where it calculates it

          So... still, what is "it"? Who fills these items? A user through some ui or some part of your code?

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rocklionmba
            wrote on last edited by
            #5

            it would be the list of items that's on the ui that the user fills out.

            1 Reply Last reply
            0
            • jeremy_kJ Offline
              jeremy_kJ Offline
              jeremy_k
              wrote on last edited by jeremy_k
              #6

              It sounds like the goal is to have something happen after several fields are filled out.

              eg Send an email after a recipient, subject, and body are entered. These can be done in any order, but a message should only be sent when all three are present.

              There's no automatic signal for an arbitrary multi-input use case, but it's easy enough to create one. Create a function that checks each input and emits a signal (or starts the calculation directly) when a valid configuration exists. void checkValid() { if (input1.isValid && input2.isValid) action(); }

              Find a change signal for each input, and call the validation function.

              Item {
                  id: input1
                  property bool isValid
                  ...
                  onChanged: checkValid()
              }
              
              Item {
                  id: input 2
                  property bool isValid
                  ...
                  onChanged: checkValid()
              }
              

              Asking a question about code? http://eel.is/iso-c++/testcase/

              1 Reply Last reply
              0
              • AmoghA Offline
                AmoghA Offline
                Amogh
                wrote on last edited by
                #7

                You have to do something to emit the signal, even if you are emitting the signal in the constructor,the constructor has to be called.

                Go to event definition,
                Type emit Your signal();
                It will automatically emit the signal when the event is occurred

                1 Reply Last reply
                1
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @rocklionmba

                  How do you know " once you finish editing" ?
                  How will app know user is finished ?

                  1 Reply Last reply
                  1

                  • Login

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