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. Connection different .ui in just mainwindow.cpp
Forum Updated to NodeBB v4.3 + New Features

Connection different .ui in just mainwindow.cpp

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 1.0k 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.
  • S Offline
    S Offline
    Stefy
    wrote on 29 May 2019, 10:39 last edited by Stefy 6 Mar 2019, 06:54
    #1

    Hi all!

    I'm new here, I need your help.
    I'm trying to connect different file .ui in a same mainwindow.cpp but obviously I need to set different name for ui.label. and so on. What can I do? Class declaration in each file?
    I would use the label present in document_interface.ui in the file mainwindow.cpp.
    I would need this because I would implement a State Machine in just one file (mainwindow.cpp) to make the SM itself more readable and clear. SM is required by vendor.!
    0_1559544892637_Screenshot_setting.jpg

    Thanks,

    Stefy

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 29 May 2019, 21:57 last edited by
      #2

      Hi and welcome to devnet,

      What will that state machine do ?
      How is it related to your widgets ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 3 Jun 2019, 06:52
      0
      • S SGaist
        29 May 2019, 21:57

        Hi and welcome to devnet,

        What will that state machine do ?
        How is it related to your widgets ?

        S Offline
        S Offline
        Stefy
        wrote on 3 Jun 2019, 06:52 last edited by
        #3

        @SGaist The SM jump from a state to another one with different action like pushing on a button. Related to each state there is a different screen window projected on a display. I would need different .ui to manage textlabels and images on display.
        Here a code of initial screen:
        0_1559544721490_Screenshot_SM.jpg

        Thanks,

        Stefy

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 3 Jun 2019, 21:33 last edited by
          #4

          And where is that state machine located ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply 4 Jun 2019, 06:16
          0
          • S SGaist
            3 Jun 2019, 21:33

            And where is that state machine located ?

            S Offline
            S Offline
            Stefy
            wrote on 4 Jun 2019, 06:16 last edited by
            #5

            @SGaist It is located in MainWindow.. and I would like (if possibile), keep all the SM in this file and try to include the different .ui label in this file. My problem is just how to connect the label of different .ui in the MainWindow (what to declare and include in this file)

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 5 Jun 2019, 20:44 last edited by
              #6

              So you have different widgets each with a corresponding .ui file ?
              If so, where are these widget created ? Also in your MainWindow ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              S 1 Reply Last reply 6 Jun 2019, 10:32
              0
              • S SGaist
                5 Jun 2019, 20:44

                So you have different widgets each with a corresponding .ui file ?
                If so, where are these widget created ? Also in your MainWindow ?

                S Offline
                S Offline
                Stefy
                wrote on 6 Jun 2019, 10:32 last edited by
                #7

                @SGaist Yes, as you can see in the image, the different .ui are located in Forms. Each .ui is linked to its .cpp. What I would like to do is link all this forms (different architecture .ui with different QLabel) in the mainwindow.cpp --> use the different QLabel belonging to different .ui in the mainwindow.cpp

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 6 Jun 2019, 21:16 last edited by
                  #8

                  In that case, you should add proper APIs to these widgets rather than trying to access their internal state. This will have the side effect to reduce drastically the maintenance cost.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  S 1 Reply Last reply 7 Jun 2019, 06:25
                  1
                  • S SGaist
                    6 Jun 2019, 21:16

                    In that case, you should add proper APIs to these widgets rather than trying to access their internal state. This will have the side effect to reduce drastically the maintenance cost.

                    S Offline
                    S Offline
                    Stefy
                    wrote on 7 Jun 2019, 06:25 last edited by
                    #9

                    @SGaist And how can I do to add API? Could you try to explain better? Thanks

                    J 1 Reply Last reply 7 Jun 2019, 06:34
                    0
                    • S Stefy
                      7 Jun 2019, 06:25

                      @SGaist And how can I do to add API? Could you try to explain better? Thanks

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 7 Jun 2019, 06:34 last edited by
                      #10

                      @Stefy said in Connection different .ui in just mainwindow.cpp:

                      And how can I do to add API?

                      Simply add public methods to your widget classes which allows other object to communicate with them.

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

                      1 Reply Last reply
                      0

                      3/10

                      3 Jun 2019, 06:52

                      topic:navigator.unread, 7
                      • Login

                      • Login or register to search.
                      3 out of 10
                      • First post
                        3/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved