Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Flipping all the Items in a Graphics View
Forum Updated to NodeBB v4.3 + New Features

Flipping all the Items in a Graphics View

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 782 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    w.h.
    wrote on last edited by w.h.
    #1

    I want to flip all the items within a graphicsview. I don't want to flip the view because I don't want to flip the coordinate system of the view. I want point(0,0) to remain in the top left corner of the sceneRect. The following codes almost does what I want. However it expands out the sceneRect by around 10 %. Any suggestion? Any more simple or elegant solutions?

    void MainWindow::flipHorizontal()
    {
    QList<QGraphicsItem*> allItems = scene->items();

      QTransform xForm;
      xForm.scale(-1,1);
      xForm.translate(-( scene->sceneRect().width() ), 0);
    
       foreach(QGraphicsItem* item, allItems)
       {
             item->setTransform(xForm);
       }
    

    }

    1 Reply Last reply
    0
    • W Offline
      W Offline
      w.h.
      wrote on last edited by
      #2

      I've seemed to have solved the problem with the scene expanding......the below seems to work quite good. But is there another way to do this that is more simple and elegant?

      void MainWindow::flipHorizontal()
      {
      QList<QGraphicsItem*> allItems = scene->items();

        QTransform xForm;
        xForm.scale(-1,1);
        xForm.translate(-( scene->sceneRect().width() ), 0);
      
         foreach(QGraphicsItem* item, allItems)
         {
               item->setTransform(xForm);
         }
      
        scene->setSceneRect(scene->itemsBoundingRect());
      

      }

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved