Results 1 to 5 of 5

Thread: How to use C++ includes?

  1. #1
    Join Date
    Jan 2006
    Posts
    15
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default How to use C++ includes?

    Hi,

    I have used Qt Designer to create a simple application, inside the form1.ui.h File I have my slot functions. In order to understand better when which part is called I wanted to print text output to stdout via cout << "we are here"; I have place the #include<iostream> inside the form1.ui.h file. Anyway the compiler complains that "cout" is not defined.

    Am I trying something really stupid? Where do I have to place the include?

    Regards,
    Jochen

  2. #2
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to use C++ includes?

    Try std::cout

  3. #3
    Join Date
    Jan 2006
    Posts
    15
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: How to use C++ includes?

    Ok, found that I have to enter the include in "Includes (in Implementation)" of Qt Designer, now I can compile. But I don't see an output...

    I expect to see some output after I click on file open, I have implemented:

    void Form1::fileOpen()
    {
    cout << "my output";
    }

    Since it uses the standard signals/slots created by default I can't see where the error is.

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

    Default Re: How to use C++ includes?

    Flush the output buffer:

    Qt Code:
    1. #include <iostream>
    2.  
    3. void Form1::fileOpen(){
    4. std::cout << "my output" << std::endl;
    5. }
    To copy to clipboard, switch view to plain text mode 

    And remember that you have to run the application from a terminal.

    BTW. It might be easier to use qDebug() instead of those cout statements.

  5. #5
    Join Date
    Jan 2006
    Posts
    15
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: How to use C++ includes?

    That works perfectly! Thanks as well for the hint with qdebug. Will have a look into this as well.

    Regards,
    Jochen

Similar Threads

  1. QImageWriter supportedImageFormats only sometimes includes JPEG. Why?
    By philw in forum Installation and Deployment
    Replies: 2
    Last Post: 17th December 2008, 23:49
  2. Pro->Makefile: how to make includes
    By Sergei82 in forum Qt Programming
    Replies: 2
    Last Post: 7th May 2008, 07:28
  3. Doubt about includes
    By xEsk in forum Newbie
    Replies: 2
    Last Post: 15th November 2007, 20:20
  4. qmake default includes
    By Gopala Krishna in forum Installation and Deployment
    Replies: 5
    Last Post: 17th July 2007, 20:47
  5. Replies: 6
    Last Post: 5th July 2007, 02:00

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.