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. Why is a thread attempted to be created, when a bool value is accessed?
Forum Updated to NodeBB v4.3 + New Features

Why is a thread attempted to be created, when a bool value is accessed?

Scheduled Pinned Locked Moved Solved General and Desktop
27 Posts 4 Posters 2.8k Views
  • 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.
  • M micha_eleric

    @Christian-Ehrlicher because the gui locks up, until all of the controls is finished. graphics on gui will not update

    Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #18

    @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

    because the gui locks up, until all of the controls is finished. graphics on gui will not update

    Then you're doing something wrong but a thread is also the wrong solution here.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    M 1 Reply Last reply
    1
    • Christian EhrlicherC Christian Ehrlicher

      @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

      because the gui locks up, until all of the controls is finished. graphics on gui will not update

      Then you're doing something wrong but a thread is also the wrong solution here.

      M Offline
      M Offline
      micha_eleric
      wrote on last edited by
      #19

      @Christian-Ehrlicher said in Why is a thread attempted to be created, when a bool value is accessed?:

      @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

      because the gui locks up, until all of the controls is finished. graphics on gui will not update

      Then you're doing something wrong but a thread is also the wrong solution here.

      it maybe the wrong solution for this snippet, but is needed for the larger program. this snippet is a small part of a " thread attempted to be created, when a bool value is accessed"

      1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

        CThreadController::EmitPortName_1()

        You defined this function but there's no implementation for it.
        If you want to be that this is a slot you should declare it as a such.

        Also why is CThreadController a QThread?

        Since m_ser_1 is not a child of CControls QObject::moveToThread() will not move it to the new thread.

        And as always - there is no need for a separate thread here.

        M Offline
        M Offline
        micha_eleric
        wrote on last edited by micha_eleric
        #20

        @Christian-Ehrlicher said in Why is a thread attempted to be created, when a bool value is accessed?:

        @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

        CThreadController::EmitPortName_1()

        You defined this function but there's no implementation for it.

        if EmitPortName_1() is defined, then it throws a moc compile error

        If you want to be that this is a slot you should declare it as a such.

        thought EmitPortName_1() was a signals

        Also why is CThreadController a QThread?

        because CThreadController is what controls [starts, makes, do thread stuff]

        Since m_ser_1 is not a child of CControls QObject::moveToThread() will not move it to the new thread.

        where is m_ser_1 attempted to be moveToThread?

        And as always - there is no need for a separate thread here.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          micha_eleric
          wrote on last edited by
          #21
          This post is deleted!
          1 Reply Last reply
          0
          • M Offline
            M Offline
            micha_eleric
            wrote on last edited by
            #22

            once

                thrCon.startThreads();
            

            was added to main.cpp, snippet gave same error as large program

            1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

              CThreadController::EmitPortName_1()

              You defined this function but there's no implementation for it.
              If you want to be that this is a slot you should declare it as a such.

              Also why is CThreadController a QThread?

              Since m_ser_1 is not a child of CControls QObject::moveToThread() will not move it to the new thread.

              And as always - there is no need for a separate thread here.

              M Offline
              M Offline
              micha_eleric
              wrote on last edited by
              #23

              @Christian-Ehrlicher said in Why is a thread attempted to be created, when a bool value is accessed?:

              Since m_ser_1 is not a child of CControls QObject::moveToThread() will not move it to the new thread.

              well, i ran with debug, and flagged

              bool open = m_ser_1.open(QIODevice::ReadWrite);
              

              the only thing it did next was

              Q_DECL_CONSTEXPR inline QFlags(Enum flags) Q_DECL_NOTHROW : i(Int(flags)) {}
              

              in qflags.h

              i was hopping for something more. maybe somewhere that call moveToThread()

              Christian EhrlicherC 1 Reply Last reply
              0
              • M micha_eleric

                @Christian-Ehrlicher said in Why is a thread attempted to be created, when a bool value is accessed?:

                Since m_ser_1 is not a child of CControls QObject::moveToThread() will not move it to the new thread.

                well, i ran with debug, and flagged

                bool open = m_ser_1.open(QIODevice::ReadWrite);
                

                the only thing it did next was

                Q_DECL_CONSTEXPR inline QFlags(Enum flags) Q_DECL_NOTHROW : i(Int(flags)) {}
                

                in qflags.h

                i was hopping for something more. maybe somewhere that call moveToThread()

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #24

                @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

                maybe somewhere that call moveToThread()

                When you would simply do what I suggested you would not have the problems but since you're ignoring me - happy coding.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                M 1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

                  maybe somewhere that call moveToThread()

                  When you would simply do what I suggested you would not have the problems but since you're ignoring me - happy coding.

                  M Offline
                  M Offline
                  micha_eleric
                  wrote on last edited by micha_eleric
                  #25

                  @Christian-Ehrlicher said in Why is a thread attempted to be created, when a bool value is accessed?:

                  @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

                  maybe somewhere that call moveToThread()

                  When you would simply do what I suggested you would not have the problems but since you're ignoring me - happy coding.

                  if i was ignoring you, then i would not have replied to you

                  i keep going back over everything said, trying to figure out what was said.

                  tried to

                  class CControls : public QSerialPort
                  

                  but it gives

                  /home/michaeleric/Qt_Creator_Projects/QSerialPortTest/CControls.cpp:5: error: type ‘QObject’ is not a direct base of ‘CControls’
                      5 | CControls::CControls() : QObject()
                        |                          ^~~~~~~
                  

                  and it was a wild guess of making m_ser_1 a child of CControls

                  making

                  QSerialPort m_ser_1
                  

                  a child of CControls, makes no sense

                  J.HilkJ 1 Reply Last reply
                  0
                  • M micha_eleric

                    @Christian-Ehrlicher said in Why is a thread attempted to be created, when a bool value is accessed?:

                    @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

                    maybe somewhere that call moveToThread()

                    When you would simply do what I suggested you would not have the problems but since you're ignoring me - happy coding.

                    if i was ignoring you, then i would not have replied to you

                    i keep going back over everything said, trying to figure out what was said.

                    tried to

                    class CControls : public QSerialPort
                    

                    but it gives

                    /home/michaeleric/Qt_Creator_Projects/QSerialPortTest/CControls.cpp:5: error: type ‘QObject’ is not a direct base of ‘CControls’
                        5 | CControls::CControls() : QObject()
                          |                          ^~~~~~~
                    

                    and it was a wild guess of making m_ser_1 a child of CControls

                    making

                    QSerialPort m_ser_1
                    

                    a child of CControls, makes no sense

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

                    @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

                    tried to
                    class CControls : public QSerialPort

                    but it gives

                    /home/michaeleric/Qt_Creator_Projects/QSerialPortTest/CControls.cpp:5: error: type ‘QObject’ is not a direct base of ‘CControls’
                    5 | CControls::CControls() : QObject()
                    | ^~~~~~~

                    seems like you forgot to change your cpp file to the new baseclass, now that you have changed it.

                    @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

                    and it was a wild guess of making m_ser_1 a child of CControls

                    It was not, its the root of your problems, actually the root of your problems is using waitForXXX functions, but thats an other topic.

                    @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

                    making
                    QSerialPort m_ser_1

                    a child of CControls, makes no sense

                    do you think that changing the base class from QObject to QSerialPort would somehow reparent your serialport instance?

                    BaseClass != parent/child relation

                    -->

                    CControls::CControls() : QObject(), m_ser_1(this)
                    {
                    }
                    

                    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.

                    M 1 Reply Last reply
                    3
                    • J.HilkJ J.Hilk

                      @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

                      tried to
                      class CControls : public QSerialPort

                      but it gives

                      /home/michaeleric/Qt_Creator_Projects/QSerialPortTest/CControls.cpp:5: error: type ‘QObject’ is not a direct base of ‘CControls’
                      5 | CControls::CControls() : QObject()
                      | ^~~~~~~

                      seems like you forgot to change your cpp file to the new baseclass, now that you have changed it.

                      @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

                      and it was a wild guess of making m_ser_1 a child of CControls

                      It was not, its the root of your problems, actually the root of your problems is using waitForXXX functions, but thats an other topic.

                      @micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:

                      making
                      QSerialPort m_ser_1

                      a child of CControls, makes no sense

                      do you think that changing the base class from QObject to QSerialPort would somehow reparent your serialport instance?

                      BaseClass != parent/child relation

                      -->

                      CControls::CControls() : QObject(), m_ser_1(this)
                      {
                      }
                      
                      M Offline
                      M Offline
                      micha_eleric
                      wrote on last edited by
                      #27

                      @J-Hilk thank you for explaining it. has one more guess of what you meant, that i was about to wild guess at. and no, i did not think what i wild guessed at would work, but worth a try.

                      1 Reply Last reply
                      0
                      • M micha_eleric has marked this topic as solved on

                      • Login

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