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.2k 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.
  • tomyT tomy

    @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.

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

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

    tomyT 1 Reply Last reply
    1
    • mrjjM mrjj

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

      tomyT Offline
      tomyT Offline
      tomy
      wrote on last edited by
      #42

      @mrjj, Hi,

      Here you are:

      0_1550504186993_2.PNG

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on 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?

        tomyT 1 Reply Last reply
        0
        • mrjjM mrjj

          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?

          tomyT Offline
          tomyT Offline
          tomy
          wrote on 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
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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.

            tomyT 1 Reply Last reply
            1
            • mrjjM mrjj

              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.

              tomyT Offline
              tomyT Offline
              tomy
              wrote on last edited by
              #46

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

              mrjjM 1 Reply Last reply
              1
              • tomyT tomy

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

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

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

                tomyT 1 Reply Last reply
                0
                • mrjjM mrjj

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

                  tomyT Offline
                  tomyT Offline
                  tomy
                  wrote on last edited by
                  #48

                  @mrjj Hi,

                  The faulty one didn't include splash stuff and was this way I think:

                  #include "myspreadsheet.h"
                  #include <QApplication>
                  
                  int main(int argc, char *argv[])
                  {
                      QApplication app(argc, argv);
                      MySpreadsheet* mySP = new MySpreadsheet;
                      mySP -> show();
                  
                      return app.exec();
                  }
                  

                  Then I added the splash stuff. Now it "apparently" is fine, but I'm still not sure not do I know of the exact reason for that red message either. :(

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

                    You are not deleting mySP. The memory will be cleaned up at the end of the application but this doesn't mean that the destructor will be called. So if you have anything there that does something it's not guaranteed to be called.

                    You should rather keep it on the stack or delete it after returning from app.exec();

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

                    1 Reply Last reply
                    3

                    • Login

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