Results 1 to 3 of 3

Thread: using qDebug for entry and exit of functions of a single class

  1. #1
    Join Date
    Apr 2016
    Posts
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default using qDebug for entry and exit of functions of a single class

    I'm adding debug messages that print when I enter and exit a function, such as:

    void MyClass::function1()
    {
    qDebug() << "enter";
    ...
    qDebug() << "exit";
    }

    QString MyClass::function2(QString input_text)
    {
    qDebug() << "enter " << input_text;
    ...
    qDebug() << "exit return = " << return_value;
    }

    I set QT_MESSAGE_PATTERN to print the function name and line number. When I compile, I use QT_NO_DEBUG to turn the print statements on and off.

    My program is very large, with probably 100 files, each containing a class. I would like a way to turn the debug statement on in a single class, while it is off for all the other classes. Any suggestions?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: using qDebug for entry and exit of functions of a single class

    Sounds like you are writing a program and you don't have confidence in how it works.

    I would add the line

    Qt Code:
    1. #define QT_NO_DEBUG
    To copy to clipboard, switch view to plain text mode 

    near the top of each cpp file (not in the header files), and do not add it as a command line compile option. If you want to turn on qDebug() statements for a certain file, comment out that line and rebuild the file.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Apr 2016
    Posts
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: using qDebug for entry and exit of functions of a single class

    Thanks. That's just what I need.

Similar Threads

  1. Multiple threads in a single class
    By Matthias81 in forum Qt Programming
    Replies: 2
    Last Post: 22nd August 2013, 07:06
  2. Calling class functions from another function
    By prophet0 in forum General Programming
    Replies: 2
    Last Post: 2nd March 2012, 21:16
  3. Replies: 3
    Last Post: 17th September 2011, 13:04
  4. class calling other class functions?
    By Hardstyle in forum Newbie
    Replies: 4
    Last Post: 2nd June 2010, 02:38
  5. DLL exporting functions, variables, class
    By Shuchi Agrawal in forum Newbie
    Replies: 1
    Last Post: 25th April 2007, 11:40

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.