Results 1 to 5 of 5

Thread: QGraphicsView/Item Tiling Problem

  1. #1
    Join Date
    Jul 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsView/Item Tiling Problem

    Hi,
    I'm trying to display the map of the world using graphics items with the graphics view. Since my world map consists of many images I'm getting some wired "grid lines" between the items which shouldn't be there. All my items coordinates are next to each other.

    I have attached a picture of what I mean.

    Antialiasing is disabled, and I also tried to set the QGraphicsView:ontAdjustForAntialiasing flag - without success.

    Any ideas?
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView/Item Tiling Problem

    All my items coordinates are next to each other.
    have you set the coordinates using setPos() or something else..

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView/Item Tiling Problem

    Did u account for pen width drawing, in boundingRect() ??
    How are u placing the items and what have u done in boundingRect() , shape() functions ?

  4. #4
    Join Date
    Jul 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView/Item Tiling Problem

    I'm placing my items using setPos

    Qt Code:
    1. //------------------------------------------------------------------------------
    2. void WorldGraphicsScene::loadSection(QString section, int x, int y, int width)
    3. {
    4. for(int i = 0; i < 16; i++)
    5. {
    6. for(int j = 0; j < 16; j++)
    7. {
    8. QFileInfo file("resources/world/" + section + "/"
    9. + section + "_" + QVariant(i).toString()
    10. + "_" + QVariant(j).toString() + ".jpg");
    11. ImageItem* image = new ImageItem(file);
    12. image->setPos(x + (i * width), y + (j * width));
    13. image->setEnabled(false);
    14. image->setDrawBorder(false);
    15.  
    16. this->addItem(image);
    17. }
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

    My boundingRect looks like this:
    Qt Code:
    1. //------------------------------------------------------------------------------
    2. QRectF BaseItem::boundingRect() const
    3. {
    4. return QRectF(0, 0, Settings::ImageWidth, Settings::ImageWidth);
    5. }
    To copy to clipboard, switch view to plain text mode 

    Do I need to implement the shape method too?

    And here my simplified drawing code:
    Qt Code:
    1. //------------------------------------------------------------------------------
    2. void ImageItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget /*= 0*/)
    3. {
    4. QRectF bounds = boundingRect();
    5. painter->drawPixmap(bounds, _image);
    6. }
    To copy to clipboard, switch view to plain text mode 

    I didn't account the pen width since I don't use a pen/outline. Do I have to?

  5. #5
    Join Date
    Jul 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView/Item Tiling Problem

    nobody?

    I also encountered an other problem: I'm using a QGraphicsView in a QStackedWidget as my centralwidget in a QMainwindow. Now I noticed that the bigger the window gets the slower my application gets. First I thought thats because there is more to display - but there isn't. I'm showing the exact same thing (couple pictures which can freely be moved and zoomed). If my window size is lets say 640x480 and I'm displaying 20 pictures its much faster than if my window is 1280x1024 and I'm displaying 20 pictures (in the exact same zoom level). Am I doing something wrong?

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  2. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  3. Replies: 16
    Last Post: 7th March 2006, 15:57

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.