what is meaning of below written statment?
-
Class* pClass = qobject_cast<Class*>(this->parent());
-
it means the project was badly designed, as the child should have no(need) knowledge of the parent
-
@Qt-embedded-developer It casts what parent() returns to Class*
Is explained here: https://doc.qt.io/qt-5/qobject.html (https://doc.qt.io/qt-5/qobject.html#qobject_cast) -
@Qt-embedded-developer I don't understand you.
Can you please describe what you want to do in an understandable way? And how threads are involved here?MyWidget* myWidget = new MyWidget(this);
-
@jsulm in MyWidget.h file i have created
class DbThread;
/*********************** DB Thread *****************************/
class DbThread: public QThread
{
Q_OBJECTpublic:
DbThread(QObject *parent = 0);
~DbThread();public:
void run();};
in run() i want to use
MyWidget* myWidget = new MyWidget(this);
will this work?
-
@Qt-embedded-developer
Hi
No it will not.
QWidgets cannot be used in another thread than the GUI thread.You can use signal and slots to talk from thread to a widgets.
-
@Qt-embedded-developer Please read https://doc.qt.io/qt-5/thread-basics.html it answers your question.