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. QPainter drawText line spacing

QPainter drawText line spacing

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 3.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.
  • ivanicyI Offline
    ivanicyI Offline
    ivanicy
    wrote on last edited by
    #1

    Hello!

    I am trying to set a line spacing when I use the drawtext function. I am using this version of the function:

    void 	drawText(const QRectF & rectangle, const QString & text, const QTextOption & option = QTextOption())
    

    But, the lines are very close and a little overlapping. Someone knows how to fix it?

    Thank you very much

    m.sueM 1 Reply Last reply
    0
    • ivanicyI ivanicy

      Hello!

      I am trying to set a line spacing when I use the drawtext function. I am using this version of the function:

      void 	drawText(const QRectF & rectangle, const QString & text, const QTextOption & option = QTextOption())
      

      But, the lines are very close and a little overlapping. Someone knows how to fix it?

      Thank you very much

      m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by
      #2

      Hi @ivanicy

      You can only get the lineSpacing using the QFontMetrics class but not set it (independent of the font size, that is). So you will have to do it yourself using the y-coordinate of the QRect in the drawText function.

      -Michael.

      1 Reply Last reply
      1
      • Vinod KuntojiV Offline
        Vinod KuntojiV Offline
        Vinod Kuntoji
        wrote on last edited by
        #3

        @ivanicy ,

        You can elide the text if it is too long, You can refer this,
        http://doc.qt.io/qt-5/qtwidgets-widgets-elidedlabel-example.html

        C++, Qt, Qt Quick Developer,
        PthinkS, Bangalore

        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