Help with QGraphicsScene, QGraphicsView



  • Hi All!

      I'm trying to develop a project for which I want to split the _mainwindow_ into multiple layouts so that I can add widgets to these layouts at a later stage without having to worry about its positioning. The _mainwindow_ layouts must look something like,
    

    | Layout 1 |

    | Layout 2 |

    | Layout 3 |

    I will be adding widgets onto this layout to display the UI on those widgets. Which is the best method to accomplish this? Should I use QGraphicsScene and QGraphicsView combo or QDockWidget? I'm not so sure about QDockWidget because I don't want the widgets to be moved. I tried setting layouts on a widget that was the centralwidget of the mainwindow but it wasn't so easy to add and delete widgets as needed. I had to reset the layouts each time. Does anybody have any ideas?
    Thanks.

    P.S. : I tries reading "this":http://qt-project.org/forums/viewthread/3119 Would it be an ideal solution for me?



  • You could add three empty QWidgets to your main screen and use a vertical layout on them. This way you can add additional layouts/widgets later without breaking the main layout.



  • I've tried that. I'm looking forward to using QGraphicsScene and QGraphicsView. Would you be knowing how I could solve my problem using the same? I've tried reading documentations and some examples from books but I can't really understand what they mean.



  • -I have a feeling you've got to go through some Qt tutorials...-

    All you need is QVBoxLayout with 3 children layouts (type is up to you to define). Then add your widgets to these children layouts. This can be done in like five clicks in the Designer. Where's your problem?

    QGraphicsView is a [derivative from] QWidget thus can be placed inside layouts. However, AFAIK it's not possible to use QLayouts inside QGraphicsScene. At least not directly. Do you really need QGraphicsScene or you just don't know what you need?

    QDockWidget is for docking windows. You don't need them as you've said.

    [quote author="holygirl" date="1359001751"]it wasn't so easy to add and delete widgets as needed. I had to reset the layouts each time.[/quote]
    Would you define "not so easy" with code sample?



  • I agree with Sergei, QGraphicsScene and QGraphicsView is mostly used for displaying 2D graphics and I'm pretty sure they aren't what you need for this problem.

    Everything you need can be achieved through layouts. I have written apps that dynamically build GUI's at run-time based on user input so I can assure you it is possible :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.