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. Eventloop and exec()
Forum Updated to NodeBB v4.3 + New Features

Eventloop and exec()

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.4k 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.
  • M Offline
    M Offline
    MokJ
    wrote on last edited by
    #1

    Whats an eventloop , and how exec() works?
    I have read the documentation of qt but I'm really looking for a bit clearer explanation.
    whats the difference between
    QThread *thread=new QThread(this);
    and
    QThread *thread=new QThread();

    QTcpSocket * socket=new QTcpSocket(this);
    and
    QTcpSocket * socket=new QTcpSocket();

    how this makes difference?

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

      Hi,

      The this parameter that you give makes the object created a child of whatever QObject based class this is.

      Did you already read the Threads and QObjects chapter of Qt's documentation ?

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

      M 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        The this parameter that you give makes the object created a child of whatever QObject based class this is.

        Did you already read the Threads and QObjects chapter of Qt's documentation ?

        M Offline
        M Offline
        MokJ
        wrote on last edited by MokJ
        #3

        @SGaist thanks , and yes I have.
        But whats confusing me is , when I'm creating an object of QTcpSocket and and I'm using the instance of a worker object instead of this does that mean that the particular QTcpSocket is the child of the worker object ?

        worker *work=new worker();
        QTcpScoket socket=new QTcpSocket(work);
        work->moveToThread(thread);
        

        and whats QEventLoop?

        JonBJ 1 Reply Last reply
        0
        • M MokJ

          @SGaist thanks , and yes I have.
          But whats confusing me is , when I'm creating an object of QTcpSocket and and I'm using the instance of a worker object instead of this does that mean that the particular QTcpSocket is the child of the worker object ?

          worker *work=new worker();
          QTcpScoket socket=new QTcpSocket(work);
          work->moveToThread(thread);
          

          and whats QEventLoop?

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

          @MokJ said in Eventloop and exec():

          QTcpScoket socket=new QTcpSocket(work);

          would indeed make the socket owned by the worker.

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

            QEventLoop, as the name suggest, represent a loop that is processing events. Events can be, for example, mouse events, windows showing and hiding, etc.

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

            1 Reply Last reply
            0

            • Login

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