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. SegFault accessing `ui->tabWidget` but there is warning about vtable entries
Forum Updated to NodeBB v4.3 + New Features

SegFault accessing `ui->tabWidget` but there is warning about vtable entries

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 5 Posters 530 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.
  • enjoysmathE enjoysmath

    @JonB Nope that didn't solve it :)

    JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by JoeCFD
    #6

    @enjoysmath

    1. click make clean and rebuild your app( better cd the build dir and do make distclean, then click run qmake)
    2. Set a break point at the beginning of that func and show which line causes crashes.
    1 Reply Last reply
    2
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #7

      Hi
      It all looks pretty normal.

      If you open one of the examples and run. Does it compile without any such errors ?

      Do you link any other libs via the pro file ?

      I have seen this error message with some nasty pointer errors.
      Do you do anything interesting with any of the Widgets ?
      Like keeping them in a list and also insert into a form or anything like that ?

      enjoysmathE 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        It all looks pretty normal.

        If you open one of the examples and run. Does it compile without any such errors ?

        Do you link any other libs via the pro file ?

        I have seen this error message with some nasty pointer errors.
        Do you do anything interesting with any of the Widgets ?
        Like keeping them in a list and also insert into a form or anything like that ?

        enjoysmathE Offline
        enjoysmathE Offline
        enjoysmath
        wrote on last edited by
        #8

        @mrjj Nope, nothing unusual. What's causing the vtable errors?

        https://github.com/enjoysmath
        https://math.stackexchange.com/users/26327/exercisingmathematician

        mrjjM 1 Reply Last reply
        0
        • enjoysmathE enjoysmath

          @mrjj Nope, nothing unusual. What's causing the vtable errors?

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

          Hi
          well actually the normal one is
          undefined reference to `vtable for
          which can be caused by not implementing virtual functions or lack
          QOBJECT macro among other things.

          But this error
          cant find Linker symbol for virtual table
          seems to be linked to both virtual function and dangling pointers.

          If i had to guess , it would be on some kind of pointer error.

          When it crashes, the call stack gives no hint on what it was doing ?

          1 Reply Last reply
          2
          • enjoysmathE Offline
            enjoysmathE Offline
            enjoysmath
            wrote on last edited by enjoysmath
            #10
            
             void MainWindow::zoomCurrentWidget(int times)
             {
                 auto widget = ui->tabWidget->currentWidget();
             
                 if (widget) {
                     auto view = dynamic_cast<ZoomableView*>(widget);
             
                     if (view)
                         view->zoomTimes(times);
                 }
            }
            

            @mrjj It's in this function where the SegFault happens. It was usually on the first line, but later the Qt Creator had me believing it was also happening further down.

            https://github.com/enjoysmath
            https://math.stackexchange.com/users/26327/exercisingmathematician

            1 Reply Last reply
            0
            • enjoysmathE Offline
              enjoysmathE Offline
              enjoysmath
              wrote on last edited by
              #11

              @mrjj It's definitely the first line. It doesn't return a working pointer to the QTabWidget, although QtCreator, when you hover over the code in Debug mode, shows that it's a QTabWidget* typed value. So there is a bug with QtCreator. I'm doing nothing special to induce this bug. Does this mean I have to go back to PyQt5 to finish my project? I thought C++ would be a lot nicer for handling large graphics scenes, but apparently there are just too many bugs.

              https://github.com/enjoysmath
              https://math.stackexchange.com/users/26327/exercisingmathematician

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

                Then you killed the tabWidget somewhere else already.

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

                enjoysmathE 1 Reply Last reply
                1
                • enjoysmathE Offline
                  enjoysmathE Offline
                  enjoysmath
                  wrote on last edited by
                  #13

                  @Christian-Ehrlicher that's the first time I'm accessing the QTabWidget.

                  https://github.com/enjoysmath
                  https://math.stackexchange.com/users/26327/exercisingmathematician

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    Then you killed the tabWidget somewhere else already.

                    enjoysmathE Offline
                    enjoysmathE Offline
                    enjoysmath
                    wrote on last edited by
                    #14

                    @Christian-Ehrlicher

                    Okay, you were right :)

                    I was doing this:

                    ```
                    

                    MainWindow w;
                    w.setCentralWidget(&view);
                    w.show();

                    
                    Which would of course wipe out the QWidget created from the UI Designer.  Thank you!
                    
                    :)

                    https://github.com/enjoysmath
                    https://math.stackexchange.com/users/26327/exercisingmathematician

                    mrjjM 1 Reply Last reply
                    2
                    • enjoysmathE enjoysmath

                      @Christian-Ehrlicher

                      Okay, you were right :)

                      I was doing this:

                      ```
                      

                      MainWindow w;
                      w.setCentralWidget(&view);
                      w.show();

                      
                      Which would of course wipe out the QWidget created from the UI Designer.  Thank you!
                      
                      :)
                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #15

                      @enjoysmath
                      Hi
                      Just as a note:

                      • Does this mean I have to go back to PyQt5 to finish my project?

                      Python version is a binding using the c++ classes so if it was a Qt bug same thing would happen in PyQt5.

                      enjoysmathE 1 Reply Last reply
                      1
                      • mrjjM mrjj

                        @enjoysmath
                        Hi
                        Just as a note:

                        • Does this mean I have to go back to PyQt5 to finish my project?

                        Python version is a binding using the c++ classes so if it was a Qt bug same thing would happen in PyQt5.

                        enjoysmathE Offline
                        enjoysmathE Offline
                        enjoysmath
                        wrote on last edited by
                        #16

                        @mrjj @Christian-Ehrlicher @JonB @JonB

                        Thanks all who helped me solve this. I will make it my duty to write an awesome software tool for my users.

                        -EnjoysMath

                        https://github.com/enjoysmath
                        https://math.stackexchange.com/users/26327/exercisingmathematician

                        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