Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. what is meaning of below written statment?

what is meaning of below written statment?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 4 Posters 765 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    Class* pClass = qobject_cast<Class*>(this->parent());

    J.HilkJ jsulmJ 2 Replies Last reply
    0
    • Q Qt embedded developer

      Class* pClass = qobject_cast<Class*>(this->parent());

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

      @Qt-embedded-developer

      it means the project was badly designed, as the child should have no(need) knowledge of the parent


      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
      4
      • Q Qt embedded developer

        Class* pClass = qobject_cast<Class*>(this->parent());

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

        @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)

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Q 1 Reply Last reply
        4
        • jsulmJ jsulm

          @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)

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by
          #4

          @jsulm if i want to create my current widget class pointer and i want to use it in same running thread of current class then what i need to write?

          jsulmJ 1 Reply Last reply
          0
          • Q Qt embedded developer

            @jsulm if i want to create my current widget class pointer and i want to use it in same running thread of current class then what i need to write?

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

            @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);
            

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            Q 1 Reply Last reply
            1
            • jsulmJ jsulm

              @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);
              
              Q Offline
              Q Offline
              Qt embedded developer
              wrote on last edited by
              #6

              @jsulm in MyWidget.h file i have created

              class DbThread;
              /*********************** DB Thread *****************************/
              class DbThread: public QThread
              {
              Q_OBJECT

              public:
              DbThread(QObject *parent = 0);
              ~DbThread();

              public:
              void run();

              };

              in run() i want to use

              MyWidget* myWidget = new MyWidget(this);

              will this work?

              mrjjM jsulmJ 2 Replies Last reply
              0
              • Q Qt embedded developer

                @jsulm in MyWidget.h file i have created

                class DbThread;
                /*********************** DB Thread *****************************/
                class DbThread: public QThread
                {
                Q_OBJECT

                public:
                DbThread(QObject *parent = 0);
                ~DbThread();

                public:
                void run();

                };

                in run() i want to use

                MyWidget* myWidget = new MyWidget(this);

                will this work?

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

                @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.

                1 Reply Last reply
                4
                • Q Qt embedded developer

                  @jsulm in MyWidget.h file i have created

                  class DbThread;
                  /*********************** DB Thread *****************************/
                  class DbThread: public QThread
                  {
                  Q_OBJECT

                  public:
                  DbThread(QObject *parent = 0);
                  ~DbThread();

                  public:
                  void run();

                  };

                  in run() i want to use

                  MyWidget* myWidget = new MyWidget(this);

                  will this work?

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

                  @Qt-embedded-developer Please read https://doc.qt.io/qt-5/thread-basics.html it answers your question.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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