Results 1 to 6 of 6

Thread: running() - Thread

  1. #1
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default running() - Thread

    Hi,
    I have a code, it is in qt-3.2 and in that code there has two function, startcapture() and stopcapture().

    In the startcapture() function, it has a sommand
    start(); // start our own thread

    I think it is for start the thread. and it is working

    but In stopcapture ther has a command

    QWaitCondition m_CaptureFinished;

    if (running()) {
    m_StopCapture = true;
    m_CaptureFinished.wait();
    qDebug("Capture thread stopped.");
    }

    I need to run it in QT4.3. I try for this, but when i make the program, it display an error like this,
    ================================================== ==========
    error: ‘running’ was not declared in this scope

    error: no matching function for call to ‘QWaitCondition::wait()’

    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qwaitcondition.h:44: note: candidates are: bool QWaitCondition::wait(QMutex*, long unsigned int)

    ================================================== ==============

    please help me

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: running() - Thread


  3. #3
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: running() - Thread

    hi
    thankyou for it and how can I ssolve this?

    QWaitCondition m_CaptureFinished;
    m_CaptureFinished.wait();

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: running() - Thread

    Solve what?

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: running() - Thread

    In Qt 4 wait needs a mutex to wait after.
    So figure it out, do you need that wait there or not?

    EDIT: I don't think that there even was a QWaitCondition in 3

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: running() - Thread

    Qt Code:
    1. QWaitCondition m_CaptureFinished;
    2.  
    3. if (running()) {
    4. m_StopCapture = true;
    5. m_CaptureFinished.wait();
    6. qDebug("Capture thread stopped.");
    7. }
    To copy to clipboard, switch view to plain text mode 
    Ok, that really makes no sense. I'm sure that code isn't from Qt 3. That works in Qt 4 only (almost ).

    Where is the mutex and why is the wait condition local? Do you have multiple threads in your application? QWaitCondition is used for synchronizing threads.

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  2. QThread: Destroyed while thread is still running
    By Shuchi Agrawal in forum Newbie
    Replies: 8
    Last Post: 3rd April 2007, 06:27
  3. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  4. how isRunning() finds thread is running?
    By quickNitin in forum Newbie
    Replies: 1
    Last Post: 13th June 2006, 08:03
  5. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.