Results 1 to 5 of 5

Thread: QGraphicsView ugly distortion yuck

  1. #1
    Join Date
    Oct 2010
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView ugly distortion yuck

    Hey.

    I've made a bug report but searching around I could not find any similar questions so I thought maybe I'm doing something wrong?


    That's QGraphicsView::scale(0.9, 0.9)... The distortion is really bad.
    (I wrote a little demo app demonstrating this)

    Now if I screenshot the app and then scale it using QImage (example), it's suddenly fine.

    My idea is to draw QGraphicsScene onto a custom buffer and then scale that using a QImage for display. Unfortunately I can't find any way to get the rendered scene.

    Can anyone give me any pointers how to do this?


    Added after 52 minutes:


    C++ Example
    I just wrote that test to show what I mean for anyone who doesn't use PySide.
    Qt Code:
    1. #include <QtGui>
    2.  
    3. #include "dialog.h"
    4.  
    5. Dialog::Dialog()
    6. {
    7. setWindowTitle(tr("Basic Layouts"));
    8. QGraphicsScene *scene = new QGraphicsScene(this);
    9. QPixmap *pic = new QPixmap("table.png");
    10. scene->addPixmap(*pic);
    11. view = new QGraphicsView();
    12. view->setScene(scene);
    13.  
    14. view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    15. view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    16. view->setAlignment(Qt::AlignLeft|Qt::AlignTop);
    17.  
    18. view->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
    19.  
    20. QPixmap *p = new QPixmap("seat_empty.png");
    21. QGraphicsPixmapItem *d = scene->addPixmap(*p);
    22. d->setPos(400,30);
    23. d = scene->addPixmap(*p);
    24. d->setPos(80,220);
    25. d = scene->addPixmap(*p);
    26. d->setPos(60,30);
    27. d = scene->addPixmap(*p);
    28. d->setPos(20,120);
    29. d = scene->addPixmap(*p);
    30. d->setPos(460,120);
    31. p = new QPixmap("other_cards.png");
    32. d = scene->addPixmap(*p);
    33. d->setPos(120,50);
    34. d = scene->addPixmap(*p);
    35. d->setPos(80,130);
    36. d = scene->addPixmap(*p);
    37. d->setPos(120,200);
    38. d = scene->addPixmap(*p);
    39. d->setPos(440,120);
    40. p = new QPixmap("6.png");
    41. d = scene->addPixmap(*p);
    42. d->setPos(540,330);
    43. p = new QPixmap("50.png");
    44. d = scene->addPixmap(*p);
    45. d->setPos(600,330);
    46.  
    47. setCentralWidget(view);
    48. show();
    49. }
    50. void Dialog::resizeEvent(QResizeEvent* event)
    51. {
    52. }
    53. void Dialog::keyPressEvent(QKeyEvent* event)
    54. {
    55. if (event->key() == Qt::Key_Equal)
    56. view->scale(1.1, 1.1);
    57. else if (event->key() == Qt::Key_Minus)
    58. view->scale(0.9, 0.9);
    59. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by genjix; 23rd October 2010 at 07:34.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGraphicsView ugly distortion yuck

    Quote Originally Posted by genjix View Post
    I just wrote that test to show what I mean for anyone who doesn't use PySide.
    That was a good idea, but posting images from a 3rd party side isn't. Please attach them on the board that your thread stays valid a long time and not depend on other sides.

    To your problem. When scaling images one will always loose informations. Sure. If you want to ensure a clear border of the cards, you have to do the painting yourself and use a cosmetic pen to draw the border. That's the only way to enforce that and also have in mind Qt (and its classes) aren't a graphics program so the transformation might be a little worser than in a real graphics problem (which also has more time to do the transformations).

    Anyway, if you use QGraphicsPixmapItem::setTransformationMode() with smooth transformation your problem should be gone.

  3. The following user says thank you to Lykurg for this useful post:

    genjix (25th October 2010)

  4. #3
    Join Date
    Oct 2010
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView ugly distortion yuck

    Aha Thank you. That was exactly what I needed, and was a great help.

    Sorry about the images; I didn't realise and will remember that in the future. I've tried re-attaching those images to this thread, but whenever I click "Manage Attachments", I just get a blank window pop-up in Firefox.

  5. #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: QGraphicsView ugly distortion yuck

    Quote Originally Posted by genjix View Post
    Sorry about the images; I didn't realise and will remember that in the future. I've tried re-attaching those images to this thread, but whenever I click "Manage Attachments", I just get a blank window pop-up in Firefox.
    You might want to try disabling AdBlock for QtCentre. We don't have any ads anyway...
    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.


  6. The following user says thank you to wysota for this useful post:

    genjix (25th October 2010)

  7. #5
    Join Date
    Oct 2010
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView ugly distortion yuck

    OK, This is not my computer but the problem was 2 add-ons for firefox:
    Torbutton 1.2.5 and GameBox 1.0.0
    Individually they work fine, but when they're both on together then the Manage Attachments form is blank.distortion1.jpgdistortion2.jpg

Similar Threads

  1. paintEvent and the strange image distortion
    By roxton in forum Qt Programming
    Replies: 0
    Last Post: 2nd September 2010, 10:30
  2. QGraphicsView
    By Yayati.Ekbote in forum Newbie
    Replies: 2
    Last Post: 4th March 2010, 15:10
  3. QDial looks too ugly, Why not improve it
    By lmax in forum Qt Tools
    Replies: 2
    Last Post: 13th March 2009, 21:03
  4. QTableView Horizontal Bar depressed, looks ugly.
    By killerwookie99 in forum Qt Programming
    Replies: 5
    Last Post: 4th March 2009, 14:01
  5. Ugly move with a top-level setMasked widget
    By nooky59 in forum Qt Programming
    Replies: 11
    Last Post: 17th December 2007, 16:26

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.