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. QCommandLineParser: help-text looks ugly

QCommandLineParser: help-text looks ugly

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 2.5k Views 3 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.
  • K Offline
    K Offline
    kaivolde
    wrote on last edited by kaivolde
    #1

    Hi,

    in my console app I'm using the QCommandLineParser. Basically it is working, but somehow the output of the parser does not look nice, e.g. if I type the help-option the whole text is written in one row and the linebreaks can be seen in the text. So formatting of the text, which is done by Qt, does not work.

    Has it something to do with the cmd-Window (on Windows 10)? But even in the Creator-output-window the text looks ugly. What is wrong?

    Thanks in advance,
    Kai

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Maybe some pictures+code would help ?
      Im not sure what u see and how u you produce the output ( bad looking one)
      Also state qt ver.

      I dont have any answer, just trying to raise ur chance of good replies :)

      1 Reply Last reply
      1
      • K Offline
        K Offline
        kaivolde
        wrote on last edited by
        #3

        OK,

        the Qt ver is 5.7beta. The use of the QCommandLineParser is pretty standard, like the example-code. The output looks like this:

        The following command:
        D:\Temp\build\ImageRename-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\debug>ImageRename.exe --help

        Produces this output (one row):
        "Usage: ImageRename.exe [options] directory\nRename files inside of a directory.\n\nOptions:\n -?, -h, --help Displays this help.\n -v, --version Displays version information.\n\nArguments:\n directory Directory containing
        the files which should be renamed.\n"

        I think the problem is that the linebreaks (\n), which are there are not "executed".

        kshegunovK 1 Reply Last reply
        0
        • K kaivolde

          OK,

          the Qt ver is 5.7beta. The use of the QCommandLineParser is pretty standard, like the example-code. The output looks like this:

          The following command:
          D:\Temp\build\ImageRename-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\debug>ImageRename.exe --help

          Produces this output (one row):
          "Usage: ImageRename.exe [options] directory\nRename files inside of a directory.\n\nOptions:\n -?, -h, --help Displays this help.\n -v, --version Displays version information.\n\nArguments:\n directory Directory containing
          the files which should be renamed.\n"

          I think the problem is that the linebreaks (\n), which are there are not "executed".

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #4

          @kaivolde said:

          Produces this output (one row):
          "Usage: ImageRename.exe [options] directory\nRename files inside of a directory.\n\nOptions:\n -?, -h, --help Displays this help.\n -v, --version Displays version information.\n\nArguments:\n directory Directory containing
          the files which should be renamed.\n"

          What's the exact line that you use for printing the help text? I'd just yesterday used that particular class and it worked perfectly fine on my machine (Linux 4,4 kernel, Qt 5.5.1). It looks like the newlines are not recognized as such (Windows actually uses the \r\n sequence for a newline).

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            If using qDebug, then there was a change in the way qDebug's output is formatted. You can find more information about it in this email thread

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kaivolde
              wrote on last edited by
              #6

              @SGaist: Yes I do the output with qDebug (and its variants):
              (impressed getting an answer from the Qt Champion, congrats btw.)

              if ( parser.isSet( helpOption )) {
                  qDebug() << parser.helpText();
                  exit( 0 );
              }
              

              Unfortunately I don't find a solution in the thread or is the solution not to use qDebug at all?

              kshegunovK 1 Reply Last reply
              0
              • K kaivolde

                @SGaist: Yes I do the output with qDebug (and its variants):
                (impressed getting an answer from the Qt Champion, congrats btw.)

                if ( parser.isSet( helpOption )) {
                    qDebug() << parser.helpText();
                    exit( 0 );
                }
                

                Unfortunately I don't find a solution in the thread or is the solution not to use qDebug at all?

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by kshegunov
                #7

                @kaivolde

                QTextStream out(stdout);
                out << parser.helpText();
                

                Should serve you just fine. Also, don't call ::exit (if that's the C exit() function) without a good reason. If you're in main return the code. If you have a running application, call the quit slot.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                2

                • Login

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