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 every time check variable value?

How to every time check variable value?

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 5 Posters 8.4k 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.
  • R rockon209

    @koahnig

    Yes I know that with Qtimer i can check the value on regular basis. But is there any other way intead of Qtimer because I have used lot of Qtimers in my Application.

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #10

    @rockon209 Can't you just emit a signal each time this variable is changed? Then everyone interested to this variable can connect to this signal and do what ever needs to be done. This way there is no need to check actively at all...

    1 Reply Last reply
    1
    • R Offline
      R Offline
      rockon209
      wrote on last edited by rockon209
      #11

      @J-Hilk @koahnig @jsulm
      I will explain again
      I pressed the start button, and I start recording some values from other sensors. And suddenly the temp value is 100 degree so therefore I want to stop the application. So when I am recording the values from other sensor I should everytime keep an eye on the temp to check the value. How can i do it. One way i know is use Qtimmer and every one seconnd check the value of the Temp sensor. Is there any other way instead of this?

      jsulmJ 2 Replies Last reply
      0
      • R rockon209

        @J-Hilk @koahnig @jsulm
        I will explain again
        I pressed the start button, and I start recording some values from other sensors. And suddenly the temp value is 100 degree so therefore I want to stop the application. So when I am recording the values from other sensor I should everytime keep an eye on the temp to check the value. How can i do it. One way i know is use Qtimmer and every one seconnd check the value of the Temp sensor. Is there any other way instead of this?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #12
        This post is deleted!
        1 Reply Last reply
        1
        • R rockon209

          @J-Hilk @koahnig @jsulm
          I will explain again
          I pressed the start button, and I start recording some values from other sensors. And suddenly the temp value is 100 degree so therefore I want to stop the application. So when I am recording the values from other sensor I should everytime keep an eye on the temp to check the value. How can i do it. One way i know is use Qtimmer and every one seconnd check the value of the Temp sensor. Is there any other way instead of this?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #13

          @rockon209 If you don't get the temperature already on a regular basis then you need to check it periodically using a QTimer. Alternative would be to have a thread where you read the temperature sleep for some time and read again in a loop. But using a QTimer is way easier!

          1 Reply Last reply
          2
          • R Offline
            R Offline
            rockon209
            wrote on last edited by rockon209
            #14

            @jsulm
            if I want to use Qthread how i can do it. I havnt used thread till now so dont know how to used it. I read about it but not able to understand.

            jsulmJ 1 Reply Last reply
            0
            • R rockon209

              @jsulm
              if I want to use Qthread how i can do it. I havnt used thread till now so dont know how to used it. I read about it but not able to understand.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by jsulm
              #15

              @rockon209 Why not just use a QTimer for that?
              If you really want to use multithreading for that then you should read:
              https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/
              http://doc.qt.io/qt-5/thread-basics.html

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rockon209
                wrote on last edited by rockon209
                #16

                @jsulm
                I dont have only one sensors but many sensors are there to measure differnt data then i think it doesnt make any sense to create different timers everytime to get the data from it. Thats why i thought to use thread.

                mrjjM 1 Reply Last reply
                0
                • R rockon209

                  @jsulm
                  I dont have only one sensors but many sensors are there to measure differnt data then i think it doesnt make any sense to create different timers everytime to get the data from it. Thats why i thought to use thread.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #17

                  @rockon209
                  There would be nothing to stop from reusing a timer. If you fear you will get too many.
                  If your design can work with 1 thread, then it can also work with one timer.

                  How many sensors are we talking about?

                  We have a system running where it uses QTimer. I think we use around 60 most of the time and have seen
                  no issue so far.

                  1 Reply Last reply
                  2
                  • R Offline
                    R Offline
                    rockon209
                    wrote on last edited by
                    #18

                    @mrjj
                    i am using around 10 sensors so may be i will need around 8 timers to get the data from them. I dont know which one is the optimum solution. Thats why i started the topic. But if you say that 60 timers are also working fine then i think i will go for timers

                    J.HilkJ jsulmJ 2 Replies Last reply
                    0
                    • R rockon209

                      @mrjj
                      i am using around 10 sensors so may be i will need around 8 timers to get the data from them. I dont know which one is the optimum solution. Thats why i started the topic. But if you say that 60 timers are also working fine then i think i will go for timers

                      J.HilkJ Online
                      J.HilkJ Online
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #19

                      @rockon209 how exactly to do communicate with your sensors? QIODevice, a file that is written, serial port, bluetooth, vendor specific library etc. Maby theres a prefabricated way/Signal that you can use as a notifier for new data available.


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      1 Reply Last reply
                      0
                      • R rockon209

                        @mrjj
                        i am using around 10 sensors so may be i will need around 8 timers to get the data from them. I dont know which one is the optimum solution. Thats why i started the topic. But if you say that 60 timers are also working fine then i think i will go for timers

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #20

                        @rockon209 How many timers you need depends on how you read all these sensors. If you read all of them at the same frequency then one timer is enough.

                        1 Reply Last reply
                        1
                        • R Offline
                          R Offline
                          rockon209
                          wrote on last edited by
                          #21

                          @J-Hilk
                          I am using different NI lib functions to communicate with these sensors.

                          @jsulm
                          I want to read the data from these sensors at different time and sometimes simultaneously. Also they have different frequencies.

                          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