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. Displaying a QGraphicsScene inside a QGraphicsView and a custom view simultaneously based on different rules?
Forum Updated to NodeBB v4.3 + New Features

Displaying a QGraphicsScene inside a QGraphicsView and a custom view simultaneously based on different rules?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 1 Posters 2.9k 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    I am having some trouble formulating my intent. Basically I want to have an ordinary QGraphicsScene that is displayed inside an ordinary QGraphicsView, however I also want to be able to display the content of the scene inside a custom view, where items are displayed based on their relationship rather than a coordinate system scene.

    Like for example I may have an item A that is very far on the coordinate system from an item B, but A is the parent of B, so if I select A inside the custom view I need B to be listed under A, which is centered since it has the focus. I know the scene is the parent of items but in my case I need to have deeper parenting for items.

    The custom view follows very simple logic. The item that has focus/ is selected is always in the center, its parents (may be multiple) on top of it, its children under it, related items on the left, siblings on the right. If another item is selected, the custom view is rearranged again.

    Which is the way to go? Do it keep the custom position as a copy to override the position of items based on item relations and move items around, restoring the custom position from the copy to revert back to the original locations of items. Or is there a way to implement a custom view that can work directly with QGraphicsScene?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mr-Merlin
      wrote on last edited by
      #2

      Hi,

      If I needed to do what you suggest, I'd maintain two scenes and views where the second scene is the one you wanted to display child-parent relationships. Then in the second scene add the children in the location you want, directly under their parents. You'll need to manage adding and removing of the child QGraphicsObjects/Widgets as you select each parent in the first scene.

      Hope I've made that clear and hope it helps.
      Simon ;O)

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #3

        I get your point, will try it out. My main concern of using two scenes was the scene acts as a manager for all objects, so the problem rises with how two scenes will share the same objects. My current approach is creating temporary widgets that use the data members from the graphic items that are related to the item in focus and displaying in a regular widget, and for now it seems to work fine, but will give your suggesting a go.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mr-Merlin
          wrote on last edited by
          #4

          In order for two scenes sharing the same object, I suggest looking at trying to split the data for the objects from the graphicsItem; create a separate object, based off QObject, with the info you want and provide signals that when that object changes, it updates the relevant items in the two scenes.

          You could also look at the model / view / controller design pattern to see where I'm going with that idea.

          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