Results 1 to 9 of 9

Thread: drawing errors

  1. #1
    Join Date
    Mar 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question drawing errors

    Hello.
    Qt 4.8.0
    QGraphicsView scale factor 3.779527559..
    The following code
    Qt Code:
    1. painter->setPen(Qt::red);
    2. painter->drawRect(0, 0, 10, 10);
    3.  
    4. painter->setPen(Qt::darkGreen);
    5. painter->drawLine(0, 3, 10, 3);
    6.  
    7. painter->setPen(Qt::blue);
    8. painter->drawLine(3, 2, 3, 7);
    9. painter->drawLine(3, 5, 8, 5);
    To copy to clipboard, switch view to plain text mode 
    gives (contrast lines in front of other drawings - just for test)
    qt1.jpg

    It is possible to adjust the view's scale factor to avoid off-lying resections, but it's unacceptable.
    May I avoid these strange sticks?

  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: drawing errors

    Do you have antialiasing enabled when drawing those lines?
    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.


  3. #3
    Join Date
    Mar 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: drawing errors

    Antialiasing disabled. With some other sizes the green line does not cover the red square by it's right end, and i could imagine some kind of explanation for this.
    But I can't explain _this_ situation.
    With Qt 4.7.x there were some problems on the opposite side (+-1 pixel precision), but it was difficult to notice.

  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: drawing errors

    Could you prepare a minimal compilable example reproducing the problem?
    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.


  5. #5
    Join Date
    Mar 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: drawing errors

    It's interesting.. Simple example draws ok. I'll try to prepare the (bad ) working example for you. Thanks

  6. #6
    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: drawing errors

    Quote Originally Posted by Dp0H View Post
    It's interesting.. Simple example draws ok.
    That's what usually happens
    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.


  7. #7
    Join Date
    Mar 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: drawing errors

    I've prepared the project:
    qtguierror.zip
    Press the buttons to animate
    That is awful..
    Last edited by Dp0H; 28th February 2012 at 06:34.

  8. #8
    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: drawing errors

    I don't have time to test everything right now but from skeeming your code I can say your setRect() implementation is somewhat incorrect (it shouldn't influence the primary problem though).

    setPos() should be expressed in the coordinate space of the parent item, so putting it in the same call as setting bounding rect for the item might be confusing for the user.

    As for the main problem I'm guessing it all have to do with inability to express every fractional number in the datatype used. Increase your scaling and all should be fine.
    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.


  9. #9
    Join Date
    Mar 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: drawing errors

    It's report designer. Current scale factor leads to 1:1 paper to screen representation. How can I just increase my scaling?
    It looks like Qt::FlatCap resolves the problem. I suggest this behaviour is incorrect for cosmetic pen.
    Last edited by Dp0H; 28th February 2012 at 07:51.

Similar Threads

  1. Qt errors?
    By nthung in forum Newbie
    Replies: 1
    Last Post: 16th October 2011, 21:33
  2. errors
    By manu in forum Newbie
    Replies: 4
    Last Post: 16th June 2008, 11:29
  3. Errors
    By hgedek in forum Newbie
    Replies: 7
    Last Post: 25th November 2007, 23:21
  4. Example with errors
    By fahmi in forum Qt Programming
    Replies: 1
    Last Post: 29th July 2007, 01:37
  5. Replies: 4
    Last Post: 17th January 2006, 17:46

Tags for this Thread

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.