Important: Please read the Qt Code of Conduct -

Is it possible to create a Qt's library project (that uses QThread/QTcpSocket) without QApplication?

  • Hi all,

    I want to use QTcpSocket/QThread in a Qt's library project (dll project). But it could not work without QApplication instance. Is there any solution in order to not use QApplication?

    Thanks advance for your helps and clarifications,

  • You can use this library from an application that creates an instance of "QCoreApplication": or QApplication.
    If the target application is not used Qt, you must create an instance of QCoreApplication in the library, and take care of their destruction.

  • I am facing exactly the same problem. Could you ellaborate a little bit, Konstantin?

    Thanks in advance.

  • Try to ask author of "this thread":, it seems that he has at least partially working solution calling QCoreApplication::exec in separated thread (in dll).

  • Thank you Bogdan. Please forgive my ignorance because I'm a beginner in Qt, but it doesn't seem like the same problem. The author of that thread has a problem regarding the use of QThread with signal and slots. What I need to do is to make several consecutive calls to the methods of QTcpSocket in the same function, such as:


    that is, without signals and sockets.

    Any help in how to structure the code would be greatly appreciated.

    Kind regards.

  • Just do as you wrote, I mean call write/read methods directly, you don't need to use signals/slots. Moreover, as far as I see read/write are not slots so you cannot connect to them even if you want.

    And I suppose you should start separated thread for your problem, as I believe your problem is far different than the main question asked in this thread.

Log in to reply