Unsolved Have a child influence another child of same parent instance.
-
I'm new to OOP and c++ but a seasoned C programmer so please be gentle.
I have a form that contains 2 sub-forms.
example:
<widget class="QWidget" name="Workspace">
...
<layout class="QHBoxLayout" name="wsmainview">
<item>
<widget class="processView" name="procView">
</widget>
</item>
<item>
<widget class="grammarEditor" name="gramEdit">
</widget>
</item>
</layout>
</widget>Both sub-forms are handled differently hence the separate classes. What I would like to know is how can I get an instance of the processView class to access data contained within the instance of the grammarEditor class of the same parent instance.
Also, if the solution is not the same, how can I have the parent class instance trigger a signal of a childs Ui?
-
@WildCode You should use signals/slots for that. In your Workspace (parent) you can connect the signals and slots from both child widgets.
http://doc.qt.io/qt-5/signalsandslots.html -
What I would like to know is how can I get an instance of the processView class to access data contained within the instance of the grammarEditor class of the same parent instance.
These views should refer to your customised data model(s).
Would you like to take another look at involved programming interfaces? -
@elfring Why do you point the OP (who is new to OOP and C++) to these complex topics?
He simply has a widget containing two other widgets, I don't see the relation to model/view/controller here. -
Why do you point the OP (who is new to OOP and C++) to these complex topics?
It is usual that it will take some time to become more familiar also with these software areas.
He simply has a widget containing two other widgets,
It can look so simple as graphical user interface design.
I don't see the relation to model/view/controller here.
- Will you stumble on programming difficulties if you omit these design components from your software development process?
- Would you like to improve the software implementation incrementally?
-
@jsulm Thankyou, this seems to be exactly what I need. Reading that page I can have the parent instance send data to a slot of a child, and have a child signal another child of changes in data. I hope I have that correct.
-
I hope I have that correct.
Which software structures will manage storage for the data in your application?
-
@WildCode Yes, any class (derived from QObject) can send and receive signals. This is one of the most important features in Qt.
-
@elfring Hi, been looking into this and getting confused as examples that interest me seem to have a little magic going on. At this point in my understanding, the best fit would be a custom tree view. I do however need some flexibility as there is more that one data source.
For example, data source B determines if data from source A is to be displayed as a parent or child, and how much data from source A is displayed in column 0. Source B is then used to process the data displayed in column 0 and the result is displayed in column 1.
So far the model view examples I have seen have only a single formatted data source which of course does not help me and only creates more confusion.
-
I do however need some flexibility as there is more that one data source.
You can switch data sources for your views, can't you?
For example, data source B determines if data from source A is to be displayed as a parent or child, and how much data from source A is displayed in column 0. Source B is then used to process the data displayed in column 0 and the result is displayed in column 1.
I find the dependencies unclear between the mentioned entities. How do you think about to represent relevant software design aspects in a data (or control) flow diagram?
… and only creates more confusion.
The view examples need to be simple generally. Do you fiddle with customised models which are more advanced?