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. qDebug() with color

qDebug() with color

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.2k Views
  • 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.
  • J Offline
    J Offline
    JacobNovitsky
    wrote on last edited by
    #1

    Is it possible to qDebug current line with some color?

    JonBJ Chris KawaC 2 Replies Last reply
    1
    • J JacobNovitsky

      Is it possible to qDebug current line with some color?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @JacobNovitsky
      You could send terminal color escape codes, but I don't think the Qt Creator debug Application Output window (it's not a "terminal") displays them or color in any user-controllable way, if that is what you mean.

      1 Reply Last reply
      0
      • J JacobNovitsky

        Is it possible to qDebug current line with some color?

        Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by Chris Kawa
        #3

        @JacobNovitsky qDebug just outputs a string to debug stream. Coloring is a function of the particular terminal/window/device that presents the stream. There's no single standard for coloring text. The receiver might not even support color. You have to refer to the specifics of your output.

        For example Qt Creator Application Output supports ANSI escape sequences, so this

        qDebug() << "\033[31mHello, I'm red text\033[0m";
        

        will print text "Hello, I'm red text" in red and then reset the color to defaults. Note that it will not work on all output devices, only those supporting ANSI codes.

        JonBJ 1 Reply Last reply
        6
        • Chris KawaC Chris Kawa

          @JacobNovitsky qDebug just outputs a string to debug stream. Coloring is a function of the particular terminal/window/device that presents the stream. There's no single standard for coloring text. The receiver might not even support color. You have to refer to the specifics of your output.

          For example Qt Creator Application Output supports ANSI escape sequences, so this

          qDebug() << "\033[31mHello, I'm red text\033[0m";
          

          will print text "Hello, I'm red text" in red and then reset the color to defaults. Note that it will not work on all output devices, only those supporting ANSI codes.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Chris-Kawa said in qDebug() with color:

          For example Qt Creator Application Output supports ANSI escape sequences

          That I didn't know, I thought it was raw output.

          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