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 & QPrinter
Forum Updated to NodeBB v4.3 + New Features

QPainter & QPrinter

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.2k Views 1 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
    KoLiBer
    wrote on last edited by
    #1

    Hi
    I have problem with qpainter direction
    I want to draw a text from right to left by drawText func but i dont know how to set direction

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @KoLiBer Check layoutDirection.

      157

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

        thanks
        I thought for printing rtl text from right of the page to left setting page dir is enough but It was a mistake

        QFont font("Arial",10);
        QFontMetrics mtc(font);
        QString text = ".....";
        painter.drawText( painter.device()->width() - mtc.width(text) , 0 , text);

        By this code i draw the text from the right of the page to left
        but apparently it has a problem
        it draws the text with gap from the right of the page and that gap is not fixed

        jsulmJ 1 Reply Last reply
        0
        • K KoLiBer

          thanks
          I thought for printing rtl text from right of the page to left setting page dir is enough but It was a mistake

          QFont font("Arial",10);
          QFontMetrics mtc(font);
          QString text = ".....";
          painter.drawText( painter.device()->width() - mtc.width(text) , 0 , text);

          By this code i draw the text from the right of the page to left
          but apparently it has a problem
          it draws the text with gap from the right of the page and that gap is not fixed

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @KoLiBer Here

          painter.drawText( painter.device()->width() - mtc.width(text) , 0 , text);
          

          you set x= painter.device()->width() - mtc.width(text)
          Why don't you just set it to painter.device()->width()? Why do you subtract mtc.width(text)?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • K Offline
            K Offline
            KoLiBer
            wrote on last edited by
            #5

            because my text direction is rtl ( persian ) and if i set x to
            painter.device()->width() entire of the text will be placed at the page out

            now i'm trying to print the page by rich text ( QTextDocument )
            at the other hand i face with the problem of width at div tag

            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