Results 1 to 12 of 12

Thread: Thread Problems (i think)

  1. #1
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Thread Problems (i think)

    I can't understand why "Cout Test" did not printing. I think this is thread problem.
    Attached Files Attached Files

  2. #2
    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: Thread Problems (i think)

    But you application doesn't use threads... Does the application output anything at all for you?

  3. #3
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Thread Problems (i think)

    Quote Originally Posted by wysota View Post
    But you application doesn't use threads... Does the application output anything at all for you?
    i think signals and slots are using threads.
    app output only via qDebug() or cerr.

  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: Thread Problems (i think)

    Quote Originally Posted by LMZ View Post
    i think signals and slots are using threads.
    No, they are not.

    app output only via qDebug() or cerr.
    What operating system are you using?

  5. #5
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Thread Problems (i think)

    Ubuntu 7.04 Feisty
    does this matter?

  6. #6
    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: Thread Problems (i think)

    Does this output anything?

    Qt Code:
    1. #include <iostream>
    2. int main(int argc, char **argv){
    3. std::cout << "TESTING" << std::endl;
    4. }
    To copy to clipboard, switch view to plain text mode 
    Compile it using qmake please, just like you would for a regular Qt app.

  7. #7
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Thread Problems (i think)

    yeap! output TESTING =))

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Thread Problems (i think)

    Seems to be missing std::endl.
    J-P Nurmi

  9. The following user says thank you to jpn for this useful post:

    LMZ (29th September 2007)

  10. #9
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Thread Problems (i think)

    Quote Originally Posted by jpn View Post
    Seems to be missing std::endl.
    std::endl is not obligatory at all

  11. #10
    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: Thread Problems (i think)

    cout works only on stdout, so you need to tell qmake this is a console app.
    Therefore add CONFIG += debug console to the pro file.

    In a GUI app you can try to output something to cerr. It might work.

  12. #11
    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: Thread Problems (i think)

    Quote Originally Posted by LMZ View Post
    std::endl is not obligatory at all
    But lack of it prevents the output buffer from being flushed. Try adding it like J-P suggested.


    Quote Originally Posted by marcel View Post
    cout works only on stdout, so you need to tell qmake this is a console app.
    Therefore add CONFIG += debug console to the pro file.

    In a GUI app you can try to output something to cerr. It might work.
    He's using Linux, so that's not the case here. That is why I asked about the OS he uses.

  13. The following user says thank you to wysota for this useful post:

    LMZ (29th September 2007)

  14. #12
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Thread Problems (i think)

    Quote Originally Posted by jpn View Post
    Seems to be missing std::endl.
    thanks a lot, it works!!!!

Similar Threads

  1. canonicalFilePath() thread problems
    By magland in forum Qt Programming
    Replies: 10
    Last Post: 5th December 2007, 22:22
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 07:13
  3. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 01:49
  4. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:44
  5. Problems with threads and windows
    By SkripT in forum Qt Programming
    Replies: 15
    Last Post: 16th January 2006, 18:46

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.