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 27 Aug 2023, 10:37 last edited by
    #1

    Is it possible to qDebug current line with some color?

    J C 2 Replies Last reply 27 Aug 2023, 11:10
    1
    • J JacobNovitsky
      27 Aug 2023, 10:37

      Is it possible to qDebug current line with some color?

      J Offline
      J Offline
      JonB
      wrote on 27 Aug 2023, 11:10 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
        27 Aug 2023, 10:37

        Is it possible to qDebug current line with some color?

        C Offline
        C Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on 27 Aug 2023, 11:23 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.

        J 1 Reply Last reply 27 Aug 2023, 16:34
        6
        • C Chris Kawa
          27 Aug 2023, 11:23

          @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.

          J Offline
          J Offline
          JonB
          wrote on 27 Aug 2023, 16:34 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

          1/4

          27 Aug 2023, 10:37

          • Login

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