Results 1 to 5 of 5

Thread: Scaling Painter without scaling the coordinate sytem

  1. #1
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Scaling Painter without scaling the coordinate sytem

    Hi guys,

    I would like to ask about one small thing. Let's say I have a text which has some width/heigh. I draw it using :
    Qt Code:
    1. painter->drawText(point,"text");
    To copy to clipboard, switch view to plain text mode 

    How to draw the same text, in the same point, but 10 times smaller?
    painter->scale(...) scales the coordinate system, but I would like to scale only the text.

    THanks
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Scaling Painter without scaling the coordinate sytem

    painter->scale(...) scales the coordinate system, but I would like to scale only the text.
    How can the text exist with out a coordinate system?

    What you do is save the current painter, then you scale, draw, and restore the saved painter.
    see QPainter for details, ask if you have more questions.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Scaling Painter without scaling the coordinate sytem

    Hi,

    I did not say that text exists without a coordinate system. Secondly I will try your suggestions.

    Thanks for help.

    Maverick


    Ok. this is the code that works, logically.

    Qt Code:
    1. painter->scale(0.001,0.001);
    2. painter->drawText(QPointF(x*1000,y*1000),"text").
    To copy to clipboard, switch view to plain text mode 

    Text is 1000 times smaller, but still in the same place.
    Last edited by maverick_pol; 7th January 2008 at 21:29.
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Scaling Painter without scaling the coordinate sytem

    I did not say that text exists without a coordinate system.
    Yes you did, but may be you were not aware of it.
    painter->scale(...) scales the coordinate system, but I would like to scale only the text.
    Text is 1000 times smaller, but still in the same place.
    Does it mean you have your problem solved?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Scaling Painter without scaling the coordinate sytem

    Hi,

    ALL in all, thank you for help and interest.
    I do appreciate your hints.

    Thanks.

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.