Assert in QTabWidgwt
-
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:

Is there any problem with my codes ?
-
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.