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. I need more than 1 line for QChart Title

I need more than 1 line for QChart Title

Scheduled Pinned Locked Moved Solved General and Desktop
qchart settitle
8 Posts 4 Posters 2.3k 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.
  • mmikeinsantarosaM Offline
    mmikeinsantarosaM Offline
    mmikeinsantarosa
    wrote on last edited by
    #1

    One line isn't long enough for the amount of text I need to place in the Title of a QChart using chart->setTitle(_chartTitleText);

    Is there a way to display more than one line of text in a QChart title?

    thanks
    Mike

    JonBJ J.HilkJ 2 Replies Last reply
    0
    • mmikeinsantarosaM mmikeinsantarosa

      One line isn't long enough for the amount of text I need to place in the Title of a QChart using chart->setTitle(_chartTitleText);

      Is there a way to display more than one line of text in a QChart title?

      thanks
      Mike

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

      @mmikeinsantarosa
      (Although I have no evidence for this, I doubt it, judging from other Qt setTitle()s.) But would it work for you if you inserted \n into your title?

      1 Reply Last reply
      1
      • mmikeinsantarosaM mmikeinsantarosa

        One line isn't long enough for the amount of text I need to place in the Title of a QChart using chart->setTitle(_chartTitleText);

        Is there a way to display more than one line of text in a QChart title?

        thanks
        Mike

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @mmikeinsantarosa The Title of a QChart is a QGraphicsTextItem so its has automatic wordwarp feature disabled by default. Therefore you'll need to add a manuel linebreak QString("\n") like @JonB suggested

        Sets the preferred width for the item's text. If the actual text is wider than the specified width then it will be broken into multiple lines.
        
        If width is set to -1 then the text will not be broken into multiple lines unless it is enforced through an explicit line break or a new paragraph.
        
        The default value is -1.
        

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        JonBJ 1 Reply Last reply
        1
        • J.HilkJ J.Hilk

          @mmikeinsantarosa The Title of a QChart is a QGraphicsTextItem so its has automatic wordwarp feature disabled by default. Therefore you'll need to add a manuel linebreak QString("\n") like @JonB suggested

          Sets the preferred width for the item's text. If the actual text is wider than the specified width then it will be broken into multiple lines.
          
          If width is set to -1 then the text will not be broken into multiple lines unless it is enforced through an explicit line break or a new paragraph.
          
          The default value is -1.
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @J.Hilk said in I need more than 1 line for QChart Title:

          so its has automatic wordwarp feature

          Sort of like in Star Trek? :)

          J.HilkJ 1 Reply Last reply
          0
          • JonBJ JonB

            @J.Hilk said in I need more than 1 line for QChart Title:

            so its has automatic wordwarp feature

            Sort of like in Star Trek? :)

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @JonB said in I need more than 1 line for QChart Title:

            @J.Hilk said in I need more than 1 line for QChart Title:

            so its has automatic wordwarp feature

            Sort of like in Star Trek? :)

            oO
            Indeed it wraps the QString with warp 10. An operation so fast, speed looses its vector, resulting in black pixel all over the boundingbox ....


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            0
            • mmikeinsantarosaM Offline
              mmikeinsantarosaM Offline
              mmikeinsantarosa
              wrote on last edited by
              #6

              Adding \n just shows up as \n in the title.
              Is there a way to enable the wordwarp in the graphicsItem?

              1 Reply Last reply
              0
              • Gojir4G Offline
                Gojir4G Offline
                Gojir4
                wrote on last edited by
                #7

                As QGraphicsTextItem support HTML, did you try using HTML ?

                chart->setTitle("My title with <br> new line);
                

                Maybe it could work. But I didn't try.

                1 Reply Last reply
                4
                • mmikeinsantarosaM Offline
                  mmikeinsantarosaM Offline
                  mmikeinsantarosa
                  wrote on last edited by
                  #8

                  Yes <br> does indeed provide another line in the title.

                  I tested it with 2 <br>'s and got 3 lines.

                  Thanks!
                  Mike

                  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