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. Line breaks in tooltip text
Forum Updated to NodeBB v4.3 + New Features

Line breaks in tooltip text

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 12.0k Views 2 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.
  • aha_1980A Offline
    aha_1980A Offline
    aha_1980
    Lifetime Qt Champion
    wrote on last edited by
    #5

    @mzimmers @mrjj:

    Stating the help: http://doc.qt.io/qt-5.9/qtooltip.html

    "Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <p style='white-space:pre'>."

    Qt has to stay free or it will die.

    mrjjM 1 Reply Last reply
    1
    • aha_1980A aha_1980

      @mzimmers @mrjj:

      Stating the help: http://doc.qt.io/qt-5.9/qtooltip.html

      "Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <p style='white-space:pre'>."

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #6

      @aha_1980
      Cheater ;) reading the docs.. \o/

      1 Reply Last reply
      0
      • aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #7

        @mrjj said in Line breaks in tooltip text:

        @aha_1980
        Cheater ;) reading the docs.. \o/

        He! Sometimes they are wrong and that makes it even harder :)

        Qt has to stay free or it will die.

        mzimmersM 1 Reply Last reply
        0
        • aha_1980A aha_1980

          @mrjj said in Line breaks in tooltip text:

          @aha_1980
          Cheater ;) reading the docs.. \o/

          He! Sometimes they are wrong and that makes it even harder :)

          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #8

          @aha_1980 I just used the settooltip() function:

              ui->plainTextEdit->setToolTip("This area contains messages received from the target device. " \
                                            "Currently target debug information is not displayed.");
          

          So is this not wrapping because it's not rich text?

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

            Hi
            Test indicates that yes
            alt text

            1 Reply Last reply
            2
            • mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by
              #10

              I'm still trying to do this programmatically, but so far without success. Here's my code:

                  QString richText = "This area contains messages received from the target device. "\
                                     "Currently target debug information is not displayed.";
                  QLabel l_toolTip;
                  l_toolTip.setText(richText);
                  l_toolTip.setTextFormat(Qt::RichText);
                  ui->plainTextEdit->setToolTip(l_toolTip.text());
              

              What am I doing wrong here?

              mrjjM 1 Reply Last reply
              0
              • mzimmersM mzimmers

                I'm still trying to do this programmatically, but so far without success. Here's my code:

                    QString richText = "This area contains messages received from the target device. "\
                                       "Currently target debug information is not displayed.";
                    QLabel l_toolTip;
                    l_toolTip.setText(richText);
                    l_toolTip.setTextFormat(Qt::RichText);
                    ui->plainTextEdit->setToolTip(l_toolTip.text());
                

                What am I doing wrong here?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #11

                @mzimmers
                That the text is not rich text.
                still just plain text.

                To cheat you can use Designer and then grab the code from
                setupUI()

                hmm. Odd using your text, it still dont word break :)

                mzimmersM 1 Reply Last reply
                0
                • mrjjM mrjj

                  @mzimmers
                  That the text is not rich text.
                  still just plain text.

                  To cheat you can use Designer and then grab the code from
                  setupUI()

                  hmm. Odd using your text, it still dont word break :)

                  mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by
                  #12

                  @mrjj it is rich text according to the debugger:

                      QString richText = "This area contains messages received from the target device. "\
                                         "Currently target debug information is not displayed.";
                      QLabel l_toolTip;
                      l_toolTip.setText(richText);
                      enum Qt::TextFormat i = l_toolTip.textFormat();
                      qDebug() << i;
                      l_toolTip.setTextFormat(Qt::RichText);
                      i = l_toolTip.textFormat();
                      qDebug() << i;
                      ui->plainTextEdit->setToolTip(l_toolTip.text());
                  

                  I get this:

                  Qt::TextFormat(AutoText)
                  Qt::TextFormat(RichText)
                  
                  1 Reply Last reply
                  0
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #13

                    hi
                    alt text

                    Rich text looks like this

                    <html><head/><body><p>this area contains messages received from the target device. Currently target debug information is not displayed</p></body></html>
                    

                    I dont think you can just lie to it about the format.

                    Code from Designer

                    pushButton->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>this area contains messages received from the target device. Currently target debug information is not displayed</p></body></html>", Q_NULLPTR));
                    
                    mzimmersM 1 Reply Last reply
                    3
                    • mrjjM mrjj

                      hi
                      alt text

                      Rich text looks like this

                      <html><head/><body><p>this area contains messages received from the target device. Currently target debug information is not displayed</p></body></html>
                      

                      I dont think you can just lie to it about the format.

                      Code from Designer

                      pushButton->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>this area contains messages received from the target device. Currently target debug information is not displayed</p></body></html>", Q_NULLPTR));
                      
                      mzimmersM Offline
                      mzimmersM Offline
                      mzimmers
                      wrote on last edited by
                      #14

                      @mrjj yeah, you're right...I just discovered that. Somewhat misleading documentation, IMO, but maybe it's just me.

                      Anyway, this works:

                              char myToolTip[] = "<html><head/><body><p>This area contains messages " \
                                  "received from the target device. " \
                                  "Currently target debug information is not displayed." \
                                  "</p></body></html>";
                          ui->plainTextEdit->setToolTip(myToolTip);
                      

                      Thanks to all for the assistance.

                      1 Reply Last reply
                      1

                      • Login

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