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. Is it possible to create a Qt's library project (that uses QThread/QTcpSocket) without QApplication?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 4.1k 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.
  • Y Offline
    Y Offline
    yaseminyilmaz
    wrote on last edited by
    #1

    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,

    1 Reply Last reply
    0
    • podsvirovP Offline
      podsvirovP Offline
      podsvirov
      wrote on last edited by
      #2

      You can use this library from an application that creates an instance of "QCoreApplication":http://qt-project.org/doc/qt-4.8/qcoreapplication.html 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.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Minipene
        wrote on last edited by
        #3

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

        Thanks in advance.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bodzio131
          wrote on last edited by
          #4

          Try to ask author of "this thread":http://qt-project.org/forums/viewthread/26483/, it seems that he has at least partially working solution calling QCoreApplication::exec in separated thread (in dll).

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Minipene
            wrote on last edited by
            #5

            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:

            @
            do_something();
            ...
            socket.write(blahblah);
            ...
            socket.read(blahblah);
            ...
            socket.write(blahblah);
            @

            that is, without signals and sockets.

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

            Kind regards.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bodzio131
              wrote on last edited by
              #6

              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.

              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