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. Include a dialog twice
Qt 6.11 is out! See what's new in the release blog

Include a dialog twice

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 7 Posters 2.4k Views 3 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.
  • M mpergand

    I want to include the same dialog class twice

    What for ?

    I get an error.

    What error ?

    S Offline
    S Offline
    Sucharek
    wrote on last edited by
    #3

    Hi @mpergand, I get it for including it in 2 different classes.
    The error:

    'theClassImIncluding' does not name a type; did you mean 'currentClass'?
    

    I'm including it by adding

    #include "theClass.h"
    

    at the top and

    private:
        theClassName class;
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Hi,

      Please show the real code.

      Your example here does not even relate to the error.

      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,

        Please show the real code.

        Your example here does not even relate to the error.

        S Offline
        S Offline
        Sucharek
        wrote on last edited by
        #5

        Hi @SGaist, here's my .h file:

        #ifndef KEYCOLOR_H
        #define KEYCOLOR_H
        
        #include "keymapping.h" //here
        #include <QDialog>
        #include <QColorDialog>
        #include <QDebug>
        
        namespace Ui {
        class keyColor;
        }
        
        class keyColor : public QDialog
        {
            Q_OBJECT
        
        public:
            explicit keyColor(QWidget *parent = nullptr);
            ~keyColor();
        
            void getMapping();
        
            QString getFirstCol() {return firstCol;}
            QString getFirstBor() {return firstBor;}
            QString getFirstTog() {return firstTog;}
        
            QString getSecondCol() {return secondCol;}
            QString getSecondBor() {return secondBor;}
            QString getSecondTog() {return secondTog;}
        
            QString getThirdCol() {return thirdCol;}
            QString getThirdBor() {return thirdBor;}
            QString getThirdTog() {return thirdTog;}
        
            QString getFourthCol() {return fourthCol;}
            QString getFourthBor() {return fourthBor;}
            QString getFourthTog() {return fourthTog;}
        
            QString getFifthCol() {return fifthCol;}
            QString getFifthBor() {return fifthBor;}
            QString getFifthTog() {return fifthTog;}
        
        private slots:
            void on_toolButton_Col1_clicked();
        
            void on_toolButton_Bor1_clicked();
        
            void on_toolButton_Tog1_clicked();
        
            void on_toolButton_Col2_clicked();
        
            void on_toolButton_Bor2_clicked();
        
            void on_toolButton_Tog2_clicked();
        
            void on_toolButton_Col3_clicked();
        
            void on_toolButton_Bor3_clicked();
        
            void on_toolButton_Tog3_clicked();
        
            void on_toolButton_Col4_clicked();
        
            void on_toolButton_Bor4_clicked();
        
            void on_toolButton_Tog4_clicked();
        
            void on_toolButton_Col5_clicked();
        
            void on_toolButton_Bor5_clicked();
        
            void on_toolButton_Tog5_clicked();
        
            void on_pushButton_Toggled_toggled(bool checked);
        
        private:
            Ui::keyColor *ui;
            keyMappingsColor map; //here
        
            QString firstCol = "200, 15, 20";
            QString firstBor;
            QString firstTog;
        
            QString secondCol;
            QString secondBor;
            QString secondTog;
        
            QString thirdCol;
            QString thirdBor;
            QString thirdTog;
        
            QString fourthCol;
            QString fourthBor;
            QString fourthTog;
        
            QString fifthCol;
            QString fifthBor;
            QString fifthTog;
        };
        
        #endif // KEYCOLOR_H
        

        The parts where //here is, are the including commands.

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

          What is keyMappingsColor ?

          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

            What is keyMappingsColor ?

            S Offline
            S Offline
            Sucharek
            wrote on last edited by
            #7

            The class I'm including

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

              That I understood.

              My question was rather: how did you implement it ?

              Is it really located in "keymapping.h" ?
              Is it in a namespace ?

              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

                That I understood.

                My question was rather: how did you implement it ?

                Is it really located in "keymapping.h" ?
                Is it in a namespace ?

                S Offline
                S Offline
                Sucharek
                wrote on last edited by
                #9

                @SGaist, I implemented including the keymapping.h as you said, and putting keyMappingColor map; in private:
                I included it in MainWindow too (the same way, but under a different name (not map but keyMap)), and it works.

                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  @Sucharek said in Include a dialog twice:

                  keyColor

                  Do oyu include this header file inside keymapping.h ? If so you've a circular include problem -> google for 'forward declaration' and remove the circular include with the help of this.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  S 1 Reply Last reply
                  1
                  • Christian EhrlicherC Christian Ehrlicher

                    @Sucharek said in Include a dialog twice:

                    keyColor

                    Do oyu include this header file inside keymapping.h ? If so you've a circular include problem -> google for 'forward declaration' and remove the circular include with the help of this.

                    S Offline
                    S Offline
                    Sucharek
                    wrote on last edited by
                    #11

                    Hi @Christian-Ehrlicher, yes I had it included in both dialogs. When I removed it in keymapping.h, I could include the in the other class, so thanks, but I have another problem, which was actually the first one I had.
                    So everytime I'm opening the dialog, I check for differences in some variables from the keymapping.h, but when I do, they don't update for some reason. Even when I try to update them in the dialog, the don't.

                    JonBJ 1 Reply Last reply
                    0
                    • S Sucharek

                      Hi @Christian-Ehrlicher, yes I had it included in both dialogs. When I removed it in keymapping.h, I could include the in the other class, so thanks, but I have another problem, which was actually the first one I had.
                      So everytime I'm opening the dialog, I check for differences in some variables from the keymapping.h, but when I do, they don't update for some reason. Even when I try to update them in the dialog, the don't.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #12

                      @Sucharek said in Include a dialog twice:

                      So everytime I'm opening the dialog, I check for differences in some variables from the keymapping.h, but when I do, they don't update for some reason. Even when I try to update them in the dialog, the don't.

                      Do you really think anyone can answer from this description?

                      S 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @Sucharek said in Include a dialog twice:

                        So everytime I'm opening the dialog, I check for differences in some variables from the keymapping.h, but when I do, they don't update for some reason. Even when I try to update them in the dialog, the don't.

                        Do you really think anyone can answer from this description?

                        S Offline
                        S Offline
                        Sucharek
                        wrote on last edited by
                        #13

                        Hi @JonB, sorry for doing a bad description. Here's a better one:
                        Everytime I execute a dialog, I have a void that sets text for buttons and gets the text from keymapping.h, but when I try to get the variables after I change some of them, they don't update. For example, I have a variable called X. I execute the keymapping dialog, and change it. Then I go to the dialog where I want to get the variable, but when I try to update it, it stays the same.

                        jsulmJ J.HilkJ 2 Replies Last reply
                        0
                        • S Sucharek

                          Hi @JonB, sorry for doing a bad description. Here's a better one:
                          Everytime I execute a dialog, I have a void that sets text for buttons and gets the text from keymapping.h, but when I try to get the variables after I change some of them, they don't update. For example, I have a variable called X. I execute the keymapping dialog, and change it. Then I go to the dialog where I want to get the variable, but when I try to update it, it stays the same.

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

                          @Sucharek Please show the code...
                          Are those really stand alone variables?
                          Declare them as "extern" to make sure you're not simply creating new variables with same name everywhere you include that header file.

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

                          1 Reply Last reply
                          0
                          • S Sucharek

                            Hi @JonB, sorry for doing a bad description. Here's a better one:
                            Everytime I execute a dialog, I have a void that sets text for buttons and gets the text from keymapping.h, but when I try to get the variables after I change some of them, they don't update. For example, I have a variable called X. I execute the keymapping dialog, and change it. Then I go to the dialog where I want to get the variable, but when I try to update it, it stays the same.

                            J.HilkJ Offline
                            J.HilkJ Offline
                            J.Hilk
                            Moderators
                            wrote on last edited by
                            #15

                            @Sucharek said in Include a dialog twice:

                            Hi @JonB, sorry for doing a bad description. Here's a better one:
                            Everytime I execute a dialog, I have a void that sets text for buttons and gets the text from keymapping.h, but when I try to get the variables after I change some of them, they don't update. For example, I have a variable called X. I execute the keymapping dialog, and change it. Then I go to the dialog where I want to get the variable, but when I try to update it, it stays the same.

                            please keep in mind, your 2 dialogs are 2 different instances, even though they share a base class, they are completely separated. That means changing stuff in the base class from inside one dialog will not ever effect stuff in the base class of the other dialog, when your program is running.


                            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                            Q: What's that?
                            A: It's blue light.
                            Q: What does it do?
                            A: It turns blue.

                            S 1 Reply Last reply
                            1
                            • J.HilkJ J.Hilk

                              @Sucharek said in Include a dialog twice:

                              Hi @JonB, sorry for doing a bad description. Here's a better one:
                              Everytime I execute a dialog, I have a void that sets text for buttons and gets the text from keymapping.h, but when I try to get the variables after I change some of them, they don't update. For example, I have a variable called X. I execute the keymapping dialog, and change it. Then I go to the dialog where I want to get the variable, but when I try to update it, it stays the same.

                              please keep in mind, your 2 dialogs are 2 different instances, even though they share a base class, they are completely separated. That means changing stuff in the base class from inside one dialog will not ever effect stuff in the base class of the other dialog, when your program is running.

                              S Offline
                              S Offline
                              Sucharek
                              wrote on last edited by
                              #16

                              Hi @J-Hilk, thanks for your answer.
                              I'll just change the variables from MainWidnow.

                              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