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. Using printf in Qt Creator app
Forum Updated to NodeBB v4.3 + New Features

Using printf in Qt Creator app

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 30.3k 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.
  • B Offline
    B Offline
    BasicPoke
    wrote on last edited by
    #1

    Hello,
    Since I mostly do embedded C, I am really used to using printf to write out debug messages and such, including all the number formatting it offers. Can easily use printf in my Qt Creator app to write to a text control or the Application Output window? If I just simply run printf("hello\n") etc, such as in a pushButton_clicked slot, I do not see the output while the app is running. Only after I exit the app, the output appears in the Application Output. Can I make it appear immediately?
    Thanks
    Ron

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BasicPoke
      wrote on last edited by
      #2

      I have an answer to my own question. I just happened to see an example of this used in the help. You use qDebug() as if it were printf():

      qDebug( "the integer is: %d", 12345 );

      Thanks
      Ron

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andreyc
        wrote on last edited by
        #3

        Also you can use it in C++ stream way
        @
        qDebug() << "the integer is" << 777;
        @
        qDebug() will add spaces between parts of a mesage and add eol character.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          The first answer contains your options but the second answer here is most informative:
          http://stackoverflow.com/questions/1716296/why-does-printf-not-flush-after-the-call-unless-a-newline-is-in-the-format-strin

          1 Reply Last reply
          0
          • B Offline
            B Offline
            BasicPoke
            wrote on last edited by
            #5

            Thanks folks

            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