Results 1 to 5 of 5

Thread: Why this doesn't work? qDebug() << "Test" << std::endl;

  1. #1
    Join Date
    May 2011
    Posts
    46
    Thanks
    5

    Default Why this doesn't work? qDebug() << "Test" << std::endl;

    error: C2228: left of '.nospace' must have class/struct/union

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Why this doesn't work? qDebug() << "Test" << std::endl;

    why do you think this should work in the first place?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    May 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why this doesn't work? qDebug() << "Test" << std::endl;

    just write

    qDebug()<<"Test";

    don't forget to include: #include <QDebug>

  4. #4
    Join Date
    Aug 2009
    Posts
    52
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why this doesn't work? qDebug() << "Test" << std::endl;

    Quote Originally Posted by grayfox View Post
    error: C2228: left of '.nospace' must have class/struct/union
    You should know that: std::endl is just a template function

    declaration:
    Qt Code:
    1. template <class charT, class traits>
    2. basic_ostream<charT,traits>& endl ( basic_ostream<charT,traits>& os );
    To copy to clipboard, switch view to plain text mode 

    and following code is equal:
    Qt Code:
    1. std::cout<<"hello"<<std::endl;
    2. std::endl(std::cout<<"hello");
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Why this doesn't work? qDebug() << "Test" << std::endl;

    std::endl is not supported by qDebug() (QDebug). This is not a STL stream!
    Every qDebug() << somthig << something; creates log in separate line.

Similar Threads

  1. QProgressBar "crash" - doesn't work properly
    By metRo_ in forum Qt Programming
    Replies: 6
    Last Post: 23rd October 2010, 13:56
  2. "unknown test function error" with MAc
    By tommy in forum Installation and Deployment
    Replies: 2
    Last Post: 22nd August 2008, 18:25
  3. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  4. Setting QFrame palette in Designer doesn't "stick"
    By Doug Broadwell in forum Qt Tools
    Replies: 1
    Last Post: 9th September 2007, 21:44
  5. Replies: 6
    Last Post: 3rd November 2006, 11:53

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.