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. Why Qt hangs?
Forum Updated to NodeBB v4.3 + New Features

Why Qt hangs?

Scheduled Pinned Locked Moved General and Desktop
11 Posts 5 Posters 3.2k 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.
  • D Offline
    D Offline
    dwsld
    wrote on last edited by
    #1

    When I create a thread with
    @HANDLE thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)MainWindow::newConntact(), NULL, 0, 0);@
    the program hangs on ClientSocket = accept(ListenSocket, NULL, NULL); in the thread.I thought that this is done in parallel.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Sorry,

      how is this question related to Qt??

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dwsld
        wrote on last edited by
        #3

        Well this happens only in qt.I mean when I push the button for the socket the program hangs.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Code_ReaQtor
          wrote on last edited by
          #4

          [quote author="dwsld" date="1363979507"]Well this happens only in qt.I mean when I push the button for the socket the program hangs.[/quote]

          I think the codes are NOT Qt-specific (I think they are M$'s API). Why not use QThread instead? It might be a problem with MOC.

          Please visit my open-source projects at https://github.com/Code-ReaQtor.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sportlover
            wrote on last edited by
            #5

            Could you please define 'hangs'?

            As I read it, you GUI freezes because the program is waiting on the accept call to return.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dwsld
              wrote on last edited by
              #6

              [quote author="NL - Danny" date="1363988269"]Could you please define 'hangs'?

              you GUI freezes because the program is waiting on the accept call to return.[/quote]

              Yes

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sportlover
                wrote on last edited by
                #7

                Check the documentation about QThread: "Click":http://qt-project.org/doc/qt-4.8/qthread.html
                Goodluck!

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dwsld
                  wrote on last edited by
                  #8

                  I have some error :
                  mainwindow.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Worker::metaObject(void)const " (?metaObject@Worker@@UBEPBUQMetaObject@@XZ).

                  mainwindow.obj:-1: error: LNK2001: unresolved external symbol "public: virtual void * __thiscall Worker::qt_metacast(char const *)" (?qt_metacast@Worker@@UAEPAXPBD@Z)

                  mainwindow.obj:-1: error: LNK2001: unresolved external symbol "public: virtual int __thiscall Worker::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Worker@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

                  @

                  class Worker : public QObject
                  {
                  Q_OBJECT

                  public slots:
                  void doWork() {
                  /* ... */
                  }
                  };

                  .....
                  QThread *thread = new QThread;
                  Worker *worker = new Worker;
                  worker->moveToThread(thread);
                  thread->start();@

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sportlover
                    wrote on last edited by
                    #9

                    Few things you could try / check:

                    • clean and rebuild
                    • Check in the implementation file if the classname is in front of the methods (Worker::doWork() etc)
                    • moc the class (run QMake)
                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      ChrisW67
                      wrote on last edited by
                      #10

                      If you were actually using the Qt networking classes there'd be no blocking by default and you almost certainly would not need the additional complexity of a thread.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mcosta
                        wrote on last edited by
                        #11

                        HI,

                        how I said in my first post, if you use non Qt classes for Networking the problem can be related only to Qt.
                        How ChrisW67 wrote, Qt Networkin classes isn't blocking

                        Please post code related to Networking

                        Once your problem is solved don't forget to:

                        • Mark the thread as SOLVED using the Topic Tool menu
                        • Vote up the answer(s) that helped you to solve the issue

                        You can embed images using (http://imgur.com/) or (http://postimage.org/)

                        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