QPainter & QPrinter



  • 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


  • Moderators



  • 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


  • Moderators

    @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)?



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.