Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved QWidget crash on creation

    General and Desktop
    1
    2
    179
    Loading More Posts
    • 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.
    • S
      sandro4912 last edited by

      I have this code based on a book with QT4. It crashes on QT5 on the creation of QWidget:

      #include <QApplication>
      
      #include <QVBoxLayout>
      #include <QSlider>
      
      int main(int argc, char** argv)
      {
          QApplication(argc, argv);
      
          QWidget base;
          QVBoxLayout layout( &base );
      
          QSlider slider( Qt::Horizontal );
      
          layout.addWidget( &slider );
      
          base.show();
      
          return QApplication::exec();
      }
      

      On crash it shows this:

      1 initFontUnlocked qguiapplication.cpp 250 0x7fecd326f61
      2 QGuiApplication::font qguiapplication.cpp 3260 0x7fecd31ddbd
      3 QFont::QFont qfont.cpp 611 0x7fecd46d185
      4 QWidgetData::QWidgetData Qt5Widgetsd 0x7fece16adb6
      5 QWidgetPrivate::QWidgetPrivate qwidget.cpp 262 0x7fece14fe1d
      6 QWidget::QWidget qwidget.cpp 1028 0x7fece13f879
      7 main main.cpp 11 0x13f113358
      8 WinMain qtmain_win.cpp 97 0x13f117dd5
      9 invoke_main exe_common.inl 107 0x13f1158dd
      10 __scrt_common_main_seh exe_common.inl 288 0x13f11578e
      11 __scrt_common_main exe_common.inl 331 0x13f11564e
      12 WinMainCRTStartup exe_winmain.cpp 17 0x13f115969
      13 BaseThreadInitThunk kernel32 0x772b556d
      14 RtlUserThreadStart ntdll 0x7741385d

      Is it not allowed to use QWdiget like this anymore?

      1 Reply Last reply Reply Quote 0
      • S
        sandro4912 last edited by

        ok this was stupid it must be

        QApplication app(argc, argv);
        

        in the first line not

        QApplication(argc, argv);
        
        1 Reply Last reply Reply Quote 1
        • S
          sandro4912 last edited by

          ok this was stupid it must be

          QApplication app(argc, argv);
          

          in the first line not

          QApplication(argc, argv);
          
          1 Reply Last reply Reply Quote 1
          • First post
            Last post