Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Multiple views one document
ChicoB last edited by
I want to have one document (data source) and multiple views of it, and the user should be able to create/close views from available options.Think about a series of data points and there would be a chart view,table view, list view, etc. All could be available in screen or layouted in a predefined manner.
So i would like to ask how can i add more than one view in a SDI in QT?
In MFC i had used MDI but limited the number of documents as one :).
I am a total beginner in QT, so what do you suggest and is there any such example ?
Did you check the "model-view classes":http://doc.qt.nokia.com/4.7-snapshot/modelview.html? They are basically meant for exactly that usecase (one model holding data and one or more views visualizing it).
ChicoB last edited by
thank you tobias, i could not make myself clear.
The problem is when visualising actually, I want each widget act like a mdi widget but basically i have one document. For example, The interview demo uses QSplitter
But I want each widget to be resizeable and can be closed at user's will.
very basic scenario without using a splitter, two widgets, one showing a chart and the other one lists tabulated values.
goetz last edited by
It is completely independent if the two views are on the same parent widget with a splitter or on two MDI subwindows. Just create the model in the right place (some controlling class or widget) and pass the pointer to the views.
giesbert last edited by
MDI in MFC really is related to documents. The views are then created by the window menu (typically).
In Qt, The QMdiArea is a Widget frame, that holds MDI sub widgets. How you create them, if each of them has an onw document or not, is totally up to you.
andre last edited by
ChicoB: how do you want to present the different views on your data? Do you want them to be separate windows, MDI subwindows? Positioned on different tabs? Items you can position in a bigger view area? The options are nearly endless, so you have to figure out a design that makes sense for your application.
Then, Gerolf is right that you can use MDI, even if you are dealing with a single document. It really doesn't matter for Qt if you actually put separate documents in your MDI window or if you just present multiple views on the same document, or if you do something else entirely in your subwindows. It is up to you.