Results 1 to 2 of 2

Thread: Problem with drawing text

  1. #1
    Join Date
    Dec 2012
    Posts
    45
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Problem with drawing text

    I am trying to draw text and m using the following code
    QPainter paint(this);
    QPen pen(QColor::QColor(255,128,00,255));
    paint.setPen(pen);


    paint.setViewport(0,0,widget_width,widget_height);
    paint.scale(1,-1);
    paint.setWindow(-widget_width /2,-widget_height/2,widget_width,widget_height);




    paint.drawText(QRectF(100,75,100,75),"Hello Qt");
    but problem is that when i am doing it it is drawing it up side down how can i draw it properly

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Problem with drawing text

    You are scaling the painter's y axis by -1 thus the text is drawn upside-down.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 7
    Last Post: 31st March 2018, 09:36
  2. Replies: 2
    Last Post: 28th October 2011, 06:46
  3. Text drawing with QPainter
    By Rambobino in forum Qt Programming
    Replies: 2
    Last Post: 1st November 2010, 17:26
  4. drawing Text
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 11
    Last Post: 15th June 2009, 09:57
  5. Drawing Text
    By QbelcorT in forum Qt Programming
    Replies: 7
    Last Post: 8th March 2009, 17:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.