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. Assert in QTabWidgwt
Qt 6.11 is out! See what's new in the release blog

Assert in QTabWidgwt

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 956 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.
  • S Offline
    S Offline
    Shayne
    wrote last edited by
    #1

    Use QTableWidget like this (Qt6.8.3 msvc2022_64):

    #include <qapplication.h>
    #include <QtWidgets/QHBoxLayout>
    #include <QtWidgets/QTreeWidget>

    class TestWidget : public QWidget
    {
    public:
    TestWidget(QWidget* pParent = nullptr)
    : QWidget(pParent)
    {
    QHBoxLayout* mainLayout = new QHBoxLayout(this);
    auto* m_pTabWidget = new QTabWidget(this);
    mainLayout->addWidget(m_pTabWidget);
    QWidget* pTabDocWidget = new QWidget(m_pTabWidget);
    m_pTabWidget->addTab(pTabDocWidget, QString("aaa"));
    }
    };

    int main(int argc, char* argv[])
    {
    QApplication app(argc, argv);
    TestWidget wid;
    wid.show();
    return app.exec();
    }

    An assert occourred in Debug Mode at "m_pTabWidget->addTab(pTabDocWidget, QString("aaa"));" , release mode is ok.

    this is the callstack:
    d08fc456-901e-4b04-853b-4b4439a723ee-image.png

    Is there any problem with my codes ?

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

      Your code above is correct so you either mix debug and release libraries (e.g. you compile your app in release mode but using debug Qt libs) or you don't show your full code.

      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
      2
      • Christian EhrlicherC Christian Ehrlicher

        Your code above is correct so you either mix debug and release libraries (e.g. you compile your app in release mode but using debug Qt libs) or you don't show your full code.

        S Offline
        S Offline
        Shayne
        wrote last edited by
        #3

        @Christian-Ehrlicher said in Assert in QTabWidgwt:

        Your code is correct. Either you’re mixing debug and release libraries together (for example, compiling your app in release mode but using debug Qt libraries), or you’re not showing the entire code.

        That’s all my code above. I encountered this issue in my project using Qt 6.7.2 (compiled by myself). I simplified the code as shown above, but the issue still persists. I think it may be a bug of qt, so i install an official release version of qt 6.8.3 and try again, but the issue still exists.

        SGaistS 1 Reply Last reply
        0
        • S Shayne

          @Christian-Ehrlicher said in Assert in QTabWidgwt:

          Your code is correct. Either you’re mixing debug and release libraries together (for example, compiling your app in release mode but using debug Qt libraries), or you’re not showing the entire code.

          That’s all my code above. I encountered this issue in my project using Qt 6.7.2 (compiled by myself). I simplified the code as shown above, but the issue still persists. I think it may be a bug of qt, so i install an official release version of qt 6.8.3 and try again, but the issue still exists.

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote last edited by
          #4

          @Shayne Hi,

          It's not your code that is doubted, it is whether there is a mix between your application being built in release mode but using debug libraries when running or vice versa. Can you check whether you are using the libraries matching your application build type ?

          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

            @Shayne Hi,

            It's not your code that is doubted, it is whether there is a mix between your application being built in release mode but using debug libraries when running or vice versa. Can you check whether you are using the libraries matching your application build type ?

            S Offline
            S Offline
            Shayne
            wrote last edited by
            #5

            @SGaist said in Assert in QTabWidgwt:

            It's not your code that is doubted, it is whether there is a mix between your application being built in release mode but using debug libraries when running or vice versa. Can you check whether you are using the libraries matching your application build type ?

            I use CMAKE to manage the dependencies, and do not add any lib manually. This issue just happened in Debug mode. I check (by my IDE , visual studio 2026 ) all libs used in my project , all of them are Debug mode. And i also check the libs in "Install directory", there is no problem either. I start the exe ( double click ) in install directory, it also has runtime crash with the message box "Debug error! xxx.exe abort() has been called ".

            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