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. Is "QSocket notifiers cannot be enabled or disabled from another thread" warning bad?
Qt 6.11 is out! See what's new in the release blog

Is "QSocket notifiers cannot be enabled or disabled from another thread" warning bad?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 2.6k 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.
  • ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on last edited by
    #1

    hi!
    I am using a socket in multiple threads and when using i get this warning message"QSocket notifiers cannot be enabled or disabled from another thread". Though the data is sent and received through that socket without any problem, i am concerned about the warning. Can anyone tell whether it is safe to neglect that warning?

    JonBJ J.HilkJ 2 Replies Last reply
    0
    • ManiRonM ManiRon

      hi!
      I am using a socket in multiple threads and when using i get this warning message"QSocket notifiers cannot be enabled or disabled from another thread". Though the data is sent and received through that socket without any problem, i am concerned about the warning. Can anyone tell whether it is safe to neglect that warning?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @ManiRon
      I'm not an expert. While you wait for one here, I think you should read through the admonitions in https://stackoverflow.com/questions/36065240/using-qtcpsockets-through-different-threads.

      ManiRonM 1 Reply Last reply
      3
      • ManiRonM ManiRon

        hi!
        I am using a socket in multiple threads and when using i get this warning message"QSocket notifiers cannot be enabled or disabled from another thread". Though the data is sent and received through that socket without any problem, i am concerned about the warning. Can anyone tell whether it is safe to neglect that warning?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @ManiRon

        Can anyone tell whether it is safe to neglect that warning?

        probably not, but no-one can stop you.

        But do tell, why are you carrying the mountain to the prophet, instead of letting the prophet walk himself ?

        What I mean, make one socket handling class, use signals to transmit the data you want to send via TcpSocket, return the received data also via Signals emitted from the tcpsocket thread. Don't carry your socket around, especially across multiple threads.


        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
        3
        • JonBJ JonB

          @ManiRon
          I'm not an expert. While you wait for one here, I think you should read through the admonitions in https://stackoverflow.com/questions/36065240/using-qtcpsockets-through-different-threads.

          ManiRonM Offline
          ManiRonM Offline
          ManiRon
          wrote on last edited by ManiRon
          #4

          @JonB @J.Hilk

          along with this can you clarify the below doubt which i asked in QT forum

          https://forum.qt.io/topic/100360/how-to-check-the-range-of-data-entered-in-qlineedit

          J.HilkJ 1 Reply Last reply
          0
          • ManiRonM ManiRon

            @JonB @J.Hilk

            along with this can you clarify the below doubt which i asked in QT forum

            https://forum.qt.io/topic/100360/how-to-check-the-range-of-data-entered-in-qlineedit

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @ManiRon I would, but I can't help you there, that has to be/should be done with a regular expression.

            For me regular expressions are magic, and I'm a Muggle.


            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.

            ManiRonM 1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              It would also be nice to show how exactly you are using that socket from multiple threads.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              ManiRonM 1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                It would also be nice to show how exactly you are using that socket from multiple threads.

                ManiRonM Offline
                ManiRonM Offline
                ManiRon
                wrote on last edited by
                #7

                @SGaist

                I created seperate thread for manage tcp operations(connect, disconnect,write, read). and put that thread in exec(). and the used signals and slot method to communicate between the threads. and the error which i mentioned is not coming now .

                1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @ManiRon I would, but I can't help you there, that has to be/should be done with a regular expression.

                  For me regular expressions are magic, and I'm a Muggle.

                  ManiRonM Offline
                  ManiRonM Offline
                  ManiRon
                  wrote on last edited by
                  #8

                  @J.Hilk @SGaist Waitforreadyread is not working inside the thread.

                  JonBJ 1 Reply Last reply
                  0
                  • ManiRonM ManiRon

                    @J.Hilk @SGaist Waitforreadyread is not working inside the thread.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @ManiRon
                    waitForReadyRead() is at best "dodgy" under Windows --- you have never said what platform you are on --- and has threading implications. Have a read through e.g. https://stackoverflow.com/questions/44544684/is-it-ok-to-use-waitforreadyread-instead-of-creating-a-slot-for-readyread. Why do you need it all, when you could design to be signal/slot instead which is better?

                    1 Reply Last reply
                    2

                    • Login

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