Why is a thread attempted to be created, when a bool value is accessed?
-
@Christian-Ehrlicher the need is the gui is to run on a different thread than the controls
@micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:
the need is the gui is to run on a different thread than the controls
Why? Qt is asynchronous...
-
@Christian-Ehrlicher when
void CGUI::Button()
calls
emit m_threadcontroller->EmitPortName_1();
it is linked to
connect(this, &CThreadController::EmitPortName_1, m_controls, &CControls::SetPortName_1);
which calls
void CControls::SetPortName_1()
which is suppose to be on a different thread than
void CGUI::Button()
@micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:
which calls
void CControls::SetPortName_1()which is suppose to be on a different thread than
I never said something else. Please properly read my answer, take a look when a member is a child of a QObject and make m_ser_1 a child of your CControls.
-
@micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:
the need is the gui is to run on a different thread than the controls
Why? Qt is asynchronous...
@Christian-Ehrlicher because the gui locks up, until all of the controls is finished. graphics on gui will not update
-
@Christian-Ehrlicher because the gui locks up, until all of the controls is finished. graphics on gui will not update
@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.
-
@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.
@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"
-
@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.
@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.
-
This post is deleted!
-
once
thrCon.startThreads();
was added to main.cpp, snippet gave same error as large program
-
@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.
@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-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()
@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.
-
@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.
@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
-
@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
@micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:
tried to
class CControls : public QSerialPortbut 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_1a 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) { }
-
@micha_eleric said in Why is a thread attempted to be created, when a bool value is accessed?:
tried to
class CControls : public QSerialPortbut 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_1a 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) { }
@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.
-