我正在关注本文,以创建一个示例Qt属性浏览器项目:https://doc.qt.io/archives/qq/qq18-propertybrowser.html
构建应用程序时,分配QtTreePropertyBrowser
对象时它会崩溃
#include <QApplication>
#include <qtpropertybrowser.h>
#include <QtIntPropertyManager>
#include <qttreepropertybrowser.h>
#include <QtEnumPropertyManager>
#include <QtEnumEditorFactory>
#include <QtGroupPropertyManager>
#include <QtSpinBoxFactory>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
/* create props
**/
auto pIntManager = new QtIntPropertyManager;
auto pPropPriority = pIntManager->addProperty("Priority");
pPropPriority->setToolTip("Task priority");
pIntManager->setRange(pPropPriority, 1, 5);
pIntManager->setValue(pPropPriority, 3);
auto pEnumManager = new QtEnumPropertyManager;
auto pReportType = pEnumManager->addProperty("Report type");
pReportType->setToolTip("Some report");
const auto types = QStringList{} << "bug" << "suggestion" << "todo";
pEnumManager->setEnumNames(pReportType, types);
pEnumManager->setValue(pReportType, 1); // "suggestion"
/* factory
**/
auto pSpinFactory = new QtSpinBoxFactory;
auto pEnumFactory = new QtEnumEditorFactory;
/* group
**/
auto pGroupManager = new QtGroupPropertyManager;
auto pTask1 = pGroupManager->addProperty("Task 1");
pTask1->addSubProperty(pPropPriority);
pTask1->addSubProperty(pReportType);
/* add props to browser
**/
auto pTreeBrowser = new QtTreePropertyBrowser; // <-- crashes here
pTreeBrowser->setFactoryForManager(pIntManager, pSpinFactory);
pTreeBrowser->setFactoryForManager(pEnumManager, pEnumFactory);
pTreeBrowser->addProperty(pTask1);
pTreeBrowser->show();
return app.exec();
}
有关该异常的更多详细信息:
未处理的异常位于0x00007FFC8A8736AE(ucrtbase.dll)中 QtGuiApplication1.exe:请求致命程序退出。