Results 1 to 4 of 4

Thread: Qt 4.1.0 QPainter

  1. #1
    Join Date
    Feb 2006
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Qt 4.1.0 QPainter

    Hi all, I just started porting my code from 3.3 to 4.1. I noticed that QPainter doesn't print as nicely as it did in 3.3. Most notably, painting on small widgets results in constricted or missing line segments. As you resize the widget, the missing lines begin to fill in.. I was just wondering if there was something to turn this off. I tried antialiasing and it made it slightly better....

    P.s I think it's great what you guys are doing, moving to this new site and all, keep up the good work to keep this community growing...

    thanks guys

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

    Default Re: Qt 4.1.0 QPainter

    You could start by showing your code

  3. #3
    Join Date
    Feb 2006
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt 4.1.0 QPainter

    hi, the problem isn't my code. I am only drawing simple shapes on a QPainter widget with a viewport and window defined so the whole thing can expand. QT4 QPainter paints differently than QT3. I think it could be because they changed the pixel width of the pen to accomidate QPolygons..

    reimplement paintEvent and put this in it, compile with qt3 and run it, then compile with qt4 and run, expand the widget and pay close attention to the lines of the rectangle, they change thicknesses with each repaint...(with qt4)

    but maybe I am doing something wrong, if you try this, let me know if you don't notice any change.


    Qt Code:
    1. QPainter myPainter;
    2. myPainter.begin(this);
    3. int shortSide = qMin(width(), height());
    4. myPainter.setViewport(((width()-shortSide)/3, (height()-shortSide)/3, shortside, shortSide);
    5. myPainter.serWindow(-50,-50,100,100);
    6. myPainter.setPen(Qt::black);
    7. myPainter.drawRect(-25,-25,45,60);
    8. myPainter.end();
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Qt 4.1.0 QPainter

    Quote Originally Posted by standrvr17
    hi, the problem isn't my code. I am only drawing simple shapes on a QPainter widget with a viewport and window defined so the whole thing can expand. QT4 QPainter paints differently than QT3. I think it could be because they changed the pixel width of the pen to accomidate QPolygons..
    I'm sure it is about your code, as other things in Qt are drawn correctly and QPainter is used for that


    reimplement paintEvent and put this in it, compile with qt3 and run it, then compile with qt4 and run, expand the widget and pay close attention to the lines of the rectangle, they change thicknesses with each repaint...(with qt4)

    but maybe I am doing something wrong, if you try this, let me know if you don't notice any change.
    No, you're not doing anything wrong.

    Qt Code:
    1. myPainter.setViewport(((width()-shortSide)/3, (height()-shortSide)/3, shortside, shortSide);
    2. myPainter.serWindow(-50,-50,100,100);
    3. myPainter.setPen(Qt::black);
    To copy to clipboard, switch view to plain text mode 

    Ok, this seems to be the problem. In Qt4 the pen size is scaled when scaling the "canvas". I guess setting the window and viewport sizes cause the canvas to be scaled (which is quite logic) and pen gets scaled with it. It's an unwanted behaviour in this situation... You may look if there is a switch, which turns this off. If not, I think you should fill in a bug report Just remember, the scaling is intended! You just want some other behaviour that the standard one, so it'll rather be a "feature request" than a bug report.
    Last edited by wysota; 6th February 2006 at 22:41.

Similar Threads

  1. QBitmap does not scale correctly with QPainter
    By macaco in forum Qt Programming
    Replies: 0
    Last Post: 8th August 2008, 11:40
  2. QPainter update()
    By csvivek in forum Qt Programming
    Replies: 5
    Last Post: 24th March 2008, 09:42
  3. QPainter and QImage
    By beerkg in forum Newbie
    Replies: 3
    Last Post: 7th September 2006, 14:48
  4. Replies: 7
    Last Post: 20th March 2006, 20:03
  5. Bugs, style changes in 4.1.0?
    By simk in forum Qt Programming
    Replies: 13
    Last Post: 13th February 2006, 11:05

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.