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.1k 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 last edited by Stefy
    #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
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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
      0
      • SGaistS SGaist

        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 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
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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
          0
          • SGaistS SGaist

            And where is that state machine located ?

            S Offline
            S Offline
            Stefy
            wrote on 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
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 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
              0
              • SGaistS SGaist

                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 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
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 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
                  1
                  • SGaistS SGaist

                    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 last edited by
                    #9

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

                    jsulmJ 1 Reply Last reply
                    0
                    • S Stefy

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

                      jsulmJ Online
                      jsulmJ Online
                      jsulm
                      Lifetime Qt Champion
                      wrote on 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

                      • Login

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