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. Access the UI, from multiple windows.
Forum Updated to NodeBB v4.3 + New Features

Access the UI, from multiple windows.

Scheduled Pinned Locked Moved Solved General and Desktop
53 Posts 4 Posters 15.9k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #36

    Hi,

    Default arguments can only be set in the function declaration. So move all = 0 to the header.

    As a matter of good practice, the parent parameter should always be last. Question of coherency with the Qt library and what other developers expects.

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

    L 2 Replies Last reply
    0
    • SGaistS SGaist

      Hi,

      Default arguments can only be set in the function declaration. So move all = 0 to the header.

      As a matter of good practice, the parent parameter should always be last. Question of coherency with the Qt library and what other developers expects.

      L Offline
      L Offline
      Loc888
      wrote on last edited by
      #37

      @SGaist Ok, i try that.

      1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Default arguments can only be set in the function declaration. So move all = 0 to the header.

        As a matter of good practice, the parent parameter should always be last. Question of coherency with the Qt library and what other developers expects.

        L Offline
        L Offline
        Loc888
        wrote on last edited by
        #38

        @SGaist I still have some errors the:

        Error: redefinition of 'Window1::Window1(Settings_Window*, QWidget*)'
        Window1::Window1(Settings_Window *TheTrueOne,QWidget *parent) : QWidget(parent),
        ^

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #39

          Do you have matching declaration and implementation ?

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

          L 1 Reply Last reply
          1
          • SGaistS SGaist

            Do you have matching declaration and implementation ?

            L Offline
            L Offline
            Loc888
            wrote on last edited by Loc888
            #40

            @SGaist

            Header :

                explicit Window1(Settings_Window *TheTrueOne = 0, QWidget *parent = 0)
                {
            
                    GivenToMe = TheTrueOne;
            
                }
            

            Source:

            Window1::Window1(Settings_Window *TheTrueOne,QWidget *parent) :         
            QWidget(parent),ui(new Ui::Window1)
            {
            ui->setupUi(this);
            }
            

            error: redefinition of 'Window1::Window1(Settings_Window*, QWidget*)'
            Window1::Window1(Settings_Window *TheTrueOne,QWidget *parent) : QWidget(parent),ui(new Ui::Window1)
            ^

            I i remove ther Settings_Window, then i have no type specified error.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #41

              You wrote the method twice: once in the header and a second time in the implementation file. That's what the compilers is complaining about. You can have only one implementation.

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

              L 1 Reply Last reply
              0
              • SGaistS SGaist

                You wrote the method twice: once in the header and a second time in the implementation file. That's what the compilers is complaining about. You can have only one implementation.

                L Offline
                L Offline
                Loc888
                wrote on last edited by Loc888
                #42

                @SGaist Men, this stuff is default... I just add some extra parameters... What should i remove?

                Ps. Ok, i fixed it.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  Loc888
                  wrote on last edited by
                  #43

                  For the love of God, this stuff is not working, i lost my patience.

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    Loc888
                    wrote on last edited by
                    #44

                    Can someone create just any working example?? I want it to compile it, and see if it's gonna work.

                    jsulmJ 1 Reply Last reply
                    0
                    • L Loc888

                      Can someone create just any working example?? I want it to compile it, and see if it's gonna work.

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

                      @Loc888 Come on it's simple. Just remove the method definition from the header file:

                      // Header :
                      
                      explicit Window1(Settings_Window *TheTrueOne = 0, QWidget *parent = 0);
                      
                      // Source:
                      
                      Window1::Window1(Settings_Window *TheTrueOne,QWidget *parent) :         
                          QWidget(parent),ui(new Ui::Window1),
                          GivenToMe(TheTrueOne)
                      {
                          ui->setupUi(this);
                      }
                      

                      Some reading about C++ would help.

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

                      L 1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @Loc888 Come on it's simple. Just remove the method definition from the header file:

                        // Header :
                        
                        explicit Window1(Settings_Window *TheTrueOne = 0, QWidget *parent = 0);
                        
                        // Source:
                        
                        Window1::Window1(Settings_Window *TheTrueOne,QWidget *parent) :         
                            QWidget(parent),ui(new Ui::Window1),
                            GivenToMe(TheTrueOne)
                        {
                            ui->setupUi(this);
                        }
                        

                        Some reading about C++ would help.

                        L Offline
                        L Offline
                        Loc888
                        wrote on last edited by Loc888
                        #46

                        @jsulm I fixed that issue.. I mean, when i change the checkBox in the other window, nothing change, and i try like 50 times and more, and same stuff, doesn't work,and i can't understand why.

                        My compiler is giving me around 50 warnings, when i create non-static data member, it is normal?

                        mrjjM 1 Reply Last reply
                        0
                        • L Loc888

                          @jsulm I fixed that issue.. I mean, when i change the checkBox in the other window, nothing change, and i try like 50 times and more, and same stuff, doesn't work,and i can't understand why.

                          My compiler is giving me around 50 warnings, when i create non-static data member, it is normal?

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #47

                          @Loc888
                          Hi
                          Nope 50 warning is not normal.
                          What does warnings say ?

                          Also, if nothing happens. Are you sure u are not creating a second copy/instance ?

                          L 1 Reply Last reply
                          0
                          • mrjjM mrjj

                            @Loc888
                            Hi
                            Nope 50 warning is not normal.
                            What does warnings say ?

                            Also, if nothing happens. Are you sure u are not creating a second copy/instance ?

                            L Offline
                            L Offline
                            Loc888
                            wrote on last edited by
                            #48

                            @mrjj

                            mainwindow.h:41: Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
                            Settings_Window* Settings_Widget = new Settings_Window;
                            ^

                            Men, i don't know about that instance.....I send you a simple project, and if you want., you can take a look, i am really tired.

                            mrjjM 1 Reply Last reply
                            0
                            • L Loc888

                              @mrjj

                              mainwindow.h:41: Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
                              Settings_Window* Settings_Widget = new Settings_Window;
                              ^

                              Men, i don't know about that instance.....I send you a simple project, and if you want., you can take a look, i am really tired.

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #49

                              @Loc888
                              Hi
                              It gives that warning if you do

                              class xxx : whatever {
                              int var =0;
                              }
                              and not using c++ 11

                              Do you have
                              Settings_Window* Settings_Widget = new Settings_Window;
                              in a. h file ?

                              Yes, please. zip project. upload to somewhere and send me link.

                              L 1 Reply Last reply
                              0
                              • mrjjM mrjj

                                @Loc888
                                Hi
                                It gives that warning if you do

                                class xxx : whatever {
                                int var =0;
                                }
                                and not using c++ 11

                                Do you have
                                Settings_Window* Settings_Widget = new Settings_Window;
                                in a. h file ?

                                Yes, please. zip project. upload to somewhere and send me link.

                                L Offline
                                L Offline
                                Loc888
                                wrote on last edited by
                                #50

                                @mrjj

                                http://www.mediafire.com/file/n9e0d3q02soc3z5/Test_3.rar

                                Yes, it's in .h file. Correct this stuff if you can, and try to compile, because i do a lot of tries, and i don't really know how it's looks like right now.

                                mrjjM 1 Reply Last reply
                                0
                                • L Loc888

                                  @mrjj

                                  http://www.mediafire.com/file/n9e0d3q02soc3z5/Test_3.rar

                                  Yes, it's in .h file. Correct this stuff if you can, and try to compile, because i do a lot of tries, and i don't really know how it's looks like right now.

                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #51

                                  @Loc888
                                  Hi
                                  Im not getting those warning.
                                  While i look in project, you can try adding
                                  CONFIG +=c++11
                                  in the .pro file.
                                  Delete all in build folder
                                  and rebuild all

                                  1 Reply Last reply
                                  0
                                  • mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #52

                                    Hi
                                    You do create a brand new mainwindow. so
                                    that is why you dont see the checked checkbox as that is in first copy

                                    void Window1::on_Check_Button_clicked()
                                    {
                                    
                                        MainWindow* W1 = new MainWindow; // not the first one, u open settings in..
                                    
                                        ui->lineEdit->setText("Is not checked.");
                                    
                                    
                                    
                                    1 Reply Last reply
                                    1
                                    • mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #53

                                      Hi
                                      Here is working project.
                                      Main issue was you created a NEW mainwindow so
                                      the setting_Widget was NOT the same as one where u checked checkbox..

                                      https://www.dropbox.com/s/nhrr9qpv76d1r07/Test_3B.zip?dl=0

                                      I fixed it to give window1 as parameter and use it that way.
                                      (as described higher up)

                                      1 Reply Last reply
                                      1

                                      • Login

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