Results 1 to 4 of 4

Thread: how to print filename and linenumber using qDebug

  1. #1
    Join Date
    Feb 2010
    Posts
    99
    Thanks
    31
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default how to print filename and linenumber using qDebug

    I am using qDebug to print debug messages. I have created customMessageHandler() which I install by calling qInstallMsgHandler() before calling qDebug. Now I want to display the filename and linenumber from which qDebug gets called. How can I do that?

    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: how to print filename and linenumber using qDebug


  3. The following user says thank you to tbscope for this useful post:

    dpatel (24th May 2010)

  4. #3
    Join Date
    Feb 2010
    Posts
    99
    Thanks
    31
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to print filename and linenumber using qDebug

    I don't get line number of the file, may be its compiler dependent, since the description says so. Thanks

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to print filename and linenumber using qDebug

    Try if
    Qt Code:
    1. qWarning() << __FILE__ << __LINE__;
    To copy to clipboard, switch view to plain text mode 
    works for you.

  6. The following user says thank you to Lykurg for this useful post:

    Ishmael (23rd June 2010)

Similar Threads

  1. how to get filename
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 24th November 2009, 08:59
  2. get filename from a QFileDialog
    By graciano in forum Qt Programming
    Replies: 2
    Last Post: 17th November 2009, 14:57
  3. How to print variables with qDebug?
    By ricardo in forum Qt Programming
    Replies: 7
    Last Post: 12th July 2009, 23:27
  4. Cancelling Long-running Print/Print Preview
    By ChrisW67 in forum Newbie
    Replies: 4
    Last Post: 16th June 2009, 23:05
  5. How can I get a filename from a different encoding?
    By Pepe in forum Qt Programming
    Replies: 4
    Last Post: 28th March 2007, 00:18

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.