Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Debugging informations with qDebug()
Qt 6.11 is out! See what's new in the release blog

Debugging informations with qDebug()

Scheduled Pinned Locked Moved General and Desktop
5 Posts 5 Posters 5.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I need every time test the (return value / return type) of a (method / simple function), the variable type or generally the behaviour of a block of code or anything else ? How can I use the qDebug() function to do this? I prefer a custom function or class that call the qDebug() and that make possible to put out debugging informations in a window attached to my application; like the debugging system but more comprehensible.

    Thanks in advance !

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      I'm not sure I get what you want. qDebug() is just a convenience class the help outputting debugging messages. For easing developers' lives it has some nice formatters for some of Qt's objects. It is not a test and verification framework. For the latter you might want to have a look at the [[Doc:QtTest]] framework, more information on the [[Doc:QTestLib Manual]].

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        [quote author="freecamellia" date="1320405908"]I prefer a custom function or class that call the qDebug() and that make possible to put out debugging informations in a window attached to my application; like the debugging system but more comprehensible.

        Thanks in advance ![/quote]

        You are looking for unit testing, or at least the use of assertions. But if you want a system that is going to "observe" your application while it is running you need either a debugger or a logger.
        In brief:

        • unit testing = to verify your code is still correct after changes and produces good output for specified input
        • debugging = to observe how values and control flows changes in your program
        • logging = to trace silently the application

        Of course, you can mix the above to get the best result depending on your wills and needs.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          I think you need just to write in your code @qDebug()<< value;@
          where value denotes the variable which is the return value or the value you want to know. You can look the output of value printed by qDebug in application output tab while the program is running.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            You can also use "qInstallMsgHandler()":http://doc.qt.nokia.com/latest/qtglobal.html#qInstallMsgHandler to make qDebug() and friends output to whereever you like.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved