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 and inheritance
Forum Updated to NodeBB v4.3 + New Features

Access and inheritance

Scheduled Pinned Locked Moved Solved General and Desktop
49 Posts 5 Posters 11.8k Views 4 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.
  • K kshegunov
    12 Feb 2019, 16:05

    @tomy said in Access and inheritance:

    Is it true for the Qt Creator compiler too? (I think so)

    Qt Creator is not a compiler, it uses some compiler (whatever you've configured), but yes, it's true for all compiler, as this is standard (and required) behaviour for C++.

    Can we conclude this way that, when the base class doesn't have a constructor, in either way, whether the subclass calls the parent's constructor (!) or it doesn't, we will get an error?

    No. Not defining a class constructor means the compiler generates a default one for you (unless specifically told otherwise). If you haven't defined a constructor in the base class, then the derived class is going to implicitly call the automatically generated one.

    T Offline
    T Offline
    tomy
    wrote on 12 Feb 2019, 18:58 last edited by
    #28

    @kshegunov

    So we will never have to call the base class's constructor from the subclass, because if there is an explicit constructor for the base class, the compiler calls (implicitly) for us (with the absence of an explicit call from us), and if there is no constructor for the base class, the compiler creates a default one and implicitly calls that in the subclass. Hence, we had better never involve ourselves with calling a base class's constructor directly (from the subclass)! :) :)

    M K 2 Replies Last reply 12 Feb 2019, 19:02
    0
    • T tomy
      12 Feb 2019, 18:58

      @kshegunov

      So we will never have to call the base class's constructor from the subclass, because if there is an explicit constructor for the base class, the compiler calls (implicitly) for us (with the absence of an explicit call from us), and if there is no constructor for the base class, the compiler creates a default one and implicitly calls that in the subclass. Hence, we had better never involve ourselves with calling a base class's constructor directly (from the subclass)! :) :)

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 12 Feb 2019, 19:02 last edited by mrjj 2 Dec 2019, 19:02
      #29

      @tomy
      Hi
      The automatic version is only for a default constructor.
      As soon as base class constructor takes parameters, it must be called from subclass as compiler cannot
      know how to obtain the parameters to give to base class.
      However the compiler will tell you that.

      1 Reply Last reply
      3
      • T tomy
        12 Feb 2019, 18:58

        @kshegunov

        So we will never have to call the base class's constructor from the subclass, because if there is an explicit constructor for the base class, the compiler calls (implicitly) for us (with the absence of an explicit call from us), and if there is no constructor for the base class, the compiler creates a default one and implicitly calls that in the subclass. Hence, we had better never involve ourselves with calling a base class's constructor directly (from the subclass)! :) :)

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 12 Feb 2019, 19:39 last edited by
        #30

        What @mrjj said, plus the moment you define a constructor, the compiler stops generating for you. Thus if you define a constructor with parameters, the compiler will not generate a default constructor for you. Beautiful system, right? :)

        Read and abide by the Qt Code of Conduct

        T 1 Reply Last reply 17 Feb 2019, 07:51
        3
        • M mrjj
          12 Feb 2019, 08:43

          @tomy
          Hi
          Nope its just how the QWidgets look.
          If you change the icons to flat style,
          it will look more "modern"

          You could use something like
          https://github.com/laserpants/qt-material-widgets
          if you want to go all in for "modern" look.

          T Offline
          T Offline
          tomy
          wrote on 13 Feb 2019, 09:16 last edited by
          #31

          @mrjj

          If you change the icons to flat style, it will look more "modern"

          Hi,
          The example you posted look very modern and stylish, but too advanced for me now. Thank you.
          I like to go step by step. So for the icons, I must download some "flat .png related files" from the Internet and substitute the old ones with these. Right?

          M 1 Reply Last reply 13 Feb 2019, 09:58
          0
          • T tomy
            13 Feb 2019, 09:16

            @mrjj

            If you change the icons to flat style, it will look more "modern"

            Hi,
            The example you posted look very modern and stylish, but too advanced for me now. Thank you.
            I like to go step by step. So for the icons, I must download some "flat .png related files" from the Internet and substitute the old ones with these. Right?

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 13 Feb 2019, 09:58 last edited by
            #32

            @tomy
            Hi
            Yes, that could be the first step.
            Maybe a bit of stylesheet to make QToolbar more flat to fit the new icons.
            I dont have an image of spreadsheet app around so im not sure what else you can
            do currently. will write of get any other ideas.

            1 Reply Last reply
            1
            • K kshegunov
              12 Feb 2019, 19:39

              What @mrjj said, plus the moment you define a constructor, the compiler stops generating for you. Thus if you define a constructor with parameters, the compiler will not generate a default constructor for you. Beautiful system, right? :)

              T Offline
              T Offline
              tomy
              wrote on 17 Feb 2019, 07:51 last edited by
              #33

              @kshegunov

              Beautiful system, right? :)

              Right. :)

              @mrjj

              Yes, that could be the first step.
              Maybe a bit of stylesheet to make QToolbar more flat to fit the new icons.
              I dont have an image of spreadsheet app around so im not sure what else you can
              do currently. will write of get any other ideas.

              Hi, Thanks. So I need to lookup "stylesheet".

              M 1 Reply Last reply 17 Feb 2019, 08:26
              0
              • T tomy
                17 Feb 2019, 07:51

                @kshegunov

                Beautiful system, right? :)

                Right. :)

                @mrjj

                Yes, that could be the first step.
                Maybe a bit of stylesheet to make QToolbar more flat to fit the new icons.
                I dont have an image of spreadsheet app around so im not sure what else you can
                do currently. will write of get any other ideas.

                Hi, Thanks. So I need to lookup "stylesheet".

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 17 Feb 2019, 08:26 last edited by
                #34

                @tomy

                Hi
                https://doc.qt.io/qt-5/stylesheet.html

                T 2 Replies Last reply 17 Feb 2019, 09:30
                1
                • M mrjj
                  17 Feb 2019, 08:26

                  @tomy

                  Hi
                  https://doc.qt.io/qt-5/stylesheet.html

                  T Offline
                  T Offline
                  tomy
                  wrote on 17 Feb 2019, 09:30 last edited by
                  #35

                  @mrjj
                  Thanks to you. :)

                  1 Reply Last reply
                  0
                  • M mrjj
                    17 Feb 2019, 08:26

                    @tomy

                    Hi
                    https://doc.qt.io/qt-5/stylesheet.html

                    T Offline
                    T Offline
                    tomy
                    wrote on 18 Feb 2019, 11:07 last edited by
                    #36

                    @mrjj Hi,

                    I created a new project called MySpreadsheet and added a few more options to the context menu and renewed the icons to flat ones.
                    Now when I run the project, it runs normally, but when we close it, the follwoing message is written in the Application Output window:

                    Starting D:\Projects\Qt\MySpreadsheet\MySpreadsheet\build-MySpreadsheet-Desktop_Qt_5_12_0_MinGW_64_bit-Debug\debug\MySpreadsheet.exe...
                    FTH: (243752): *** Fault tolerant heap shim applied to current process. This is usually due to previous crashes. ***
                    The program has unexpectedly finished.
                    The process was ended forcefully.
                    D:/Projects/Qt/MySpreadsheet/MySpreadsheet/build-MySpreadsheet-Desktop_Qt_5_12_0_MinGW_64_bit-Debug/debug/MySpreadsheet.exe crashed.

                    What is the problem please?
                    Is it not related to the .pro file, please?

                    J 1 Reply Last reply 18 Feb 2019, 14:11
                    0
                    • T tomy
                      18 Feb 2019, 11:07

                      @mrjj Hi,

                      I created a new project called MySpreadsheet and added a few more options to the context menu and renewed the icons to flat ones.
                      Now when I run the project, it runs normally, but when we close it, the follwoing message is written in the Application Output window:

                      Starting D:\Projects\Qt\MySpreadsheet\MySpreadsheet\build-MySpreadsheet-Desktop_Qt_5_12_0_MinGW_64_bit-Debug\debug\MySpreadsheet.exe...
                      FTH: (243752): *** Fault tolerant heap shim applied to current process. This is usually due to previous crashes. ***
                      The program has unexpectedly finished.
                      The process was ended forcefully.
                      D:/Projects/Qt/MySpreadsheet/MySpreadsheet/build-MySpreadsheet-Desktop_Qt_5_12_0_MinGW_64_bit-Debug/debug/MySpreadsheet.exe crashed.

                      What is the problem please?
                      Is it not related to the .pro file, please?

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 18 Feb 2019, 14:11 last edited by
                      #37

                      @tomy Please run through debugger and post stack trace after it crashed...

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

                      T 1 Reply Last reply 18 Feb 2019, 14:21
                      0
                      • J jsulm
                        18 Feb 2019, 14:11

                        @tomy Please run through debugger and post stack trace after it crashed...

                        T Offline
                        T Offline
                        tomy
                        wrote on 18 Feb 2019, 14:21 last edited by
                        #38

                        @jsulm
                        Do you mean by pressing F5, please?
                        If so, I did it, but how to post stack trace?

                        0_1550499661735_Capture_1.PNG

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 18 Feb 2019, 14:26 last edited by
                          #39

                          Hi
                          It is the list to the right we are after

                          The code
                          for entries Level 2,3 would help a lot.

                          T 1 Reply Last reply 18 Feb 2019, 14:36
                          2
                          • M mrjj
                            18 Feb 2019, 14:26

                            Hi
                            It is the list to the right we are after

                            The code
                            for entries Level 2,3 would help a lot.

                            T Offline
                            T Offline
                            tomy
                            wrote on 18 Feb 2019, 14:36 last edited by
                            #40

                            @mrjj,
                            Hi,

                            0_1550500483783_1.PNG

                            Do you mean I copy and paste code for level 7 and 11 here?
                            7 is the project's code but 11 includes thousands of lines of code.

                            M 1 Reply Last reply 18 Feb 2019, 15:31
                            0
                            • T tomy
                              18 Feb 2019, 14:36

                              @mrjj,
                              Hi,

                              0_1550500483783_1.PNG

                              Do you mean I copy and paste code for level 7 and 11 here?
                              7 is the project's code but 11 includes thousands of lines of code.

                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 18 Feb 2019, 15:31 last edited by
                              #41

                              @tomy
                              Hi
                              The line it shows when you click on 11 ? line 1339

                              T 1 Reply Last reply 18 Feb 2019, 15:36
                              1
                              • M mrjj
                                18 Feb 2019, 15:31

                                @tomy
                                Hi
                                The line it shows when you click on 11 ? line 1339

                                T Offline
                                T Offline
                                tomy
                                wrote on 18 Feb 2019, 15:36 last edited by
                                #42

                                @mrjj, Hi,

                                Here you are:

                                0_1550504186993_2.PNG

                                1 Reply Last reply
                                0
                                • M Offline
                                  M Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on 18 Feb 2019, 17:11 last edited by
                                  #43

                                  Hi
                                  it was not what i as i had hoped, it being inside some of the user code.
                                  I wonder if you have a double free.
                                  Did you change anything in main.cpp?

                                  T 1 Reply Last reply 18 Feb 2019, 17:31
                                  0
                                  • M mrjj
                                    18 Feb 2019, 17:11

                                    Hi
                                    it was not what i as i had hoped, it being inside some of the user code.
                                    I wonder if you have a double free.
                                    Did you change anything in main.cpp?

                                    T Offline
                                    T Offline
                                    tomy
                                    wrote on 18 Feb 2019, 17:31 last edited by tomy
                                    #44

                                    @mrjj Hi,

                                    Here is main.cpp:

                                    #include "myspreadsheet.h"
                                    #include <QApplication>
                                    #include <QSplashScreen>
                                    
                                    int main(int argc, char *argv[])
                                    {
                                        QApplication app(argc, argv);
                                    
                                        QSplashScreen* splash = new QSplashScreen;
                                        splash->setPixmap(QPixmap(":/images/splash.jpg"));
                                        splash->show();
                                    
                                        Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
                                        splash->showMessage(QObject::tr("Setting up the main window..."), topRight, Qt::white);
                                    
                                    
                                        MySpreadsheet* mySP = new MySpreadsheet;
                                        if(argc > 1)
                                            mySP -> loadFile(argv[1]);
                                    
                                        mySP -> show();
                                        splash -> finish(mySP);
                                        delete splash;
                                    
                                        return app.exec();
                                    }
                                    

                                    I added those splash stuff and now apparently it's fine!

                                    1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on 18 Feb 2019, 17:34 last edited by
                                      #45

                                      Hi
                                      Does look fine.
                                      Try set breakpoint in main.cpp and press f10 to signle step over it and
                                      see if we can find the reason for the crash.
                                      Since its first on close, it might be inside MySpreadsheet indirectly.

                                      T 1 Reply Last reply 18 Feb 2019, 18:31
                                      1
                                      • M mrjj
                                        18 Feb 2019, 17:34

                                        Hi
                                        Does look fine.
                                        Try set breakpoint in main.cpp and press f10 to signle step over it and
                                        see if we can find the reason for the crash.
                                        Since its first on close, it might be inside MySpreadsheet indirectly.

                                        T Offline
                                        T Offline
                                        tomy
                                        wrote on 18 Feb 2019, 18:31 last edited by
                                        #46

                                        @mrjj
                                        Hi, It's fine now. :) Thanks so much. :)

                                        M 1 Reply Last reply 18 Feb 2019, 20:00
                                        1
                                        • T tomy
                                          18 Feb 2019, 18:31

                                          @mrjj
                                          Hi, It's fine now. :) Thanks so much. :)

                                          M Offline
                                          M Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on 18 Feb 2019, 20:00 last edited by
                                          #47

                                          @tomy
                                          Hi
                                          What was it ? Just to learn also.

                                          T 1 Reply Last reply 18 Feb 2019, 21:38
                                          0

                                          37/49

                                          18 Feb 2019, 14:11

                                          • Login

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