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. Have a child influence another child of same parent instance.

Have a child influence another child of same parent instance.

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 1.3k 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
    WildCode
    wrote on last edited by
    #1

    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?

    jsulmJ E 2 Replies Last reply
    0
    • W WildCode

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      W 1 Reply Last reply
      3
      • W WildCode

        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?

        E Offline
        E Offline
        elfring
        wrote on last edited by
        #3

        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?

        jsulmJ W 2 Replies Last reply
        0
        • E elfring

          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?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          E 1 Reply Last reply
          0
          • jsulmJ jsulm

            @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.

            E Offline
            E Offline
            elfring
            wrote on last edited by
            #5

            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?
            1 Reply Last reply
            0
            • jsulmJ jsulm

              @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

              W Offline
              W Offline
              WildCode
              wrote on last edited by
              #6

              @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.

              E jsulmJ 2 Replies Last reply
              0
              • W WildCode

                @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.

                E Offline
                E Offline
                elfring
                wrote on last edited by
                #7

                I hope I have that correct.

                Which software structures will manage storage for the data in your application?

                1 Reply Last reply
                0
                • W WildCode

                  @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.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @WildCode Yes, any class (derived from QObject) can send and receive signals. This is one of the most important features in Qt.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  3
                  • E elfring

                    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?

                    W Offline
                    W Offline
                    WildCode
                    wrote on last edited by
                    #9

                    @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.

                    E 1 Reply Last reply
                    0
                    • W WildCode

                      @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.

                      E Offline
                      E Offline
                      elfring
                      wrote on last edited by
                      #10

                      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?

                      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