最近做项目,开始做就卡了壳,以前从来没碰到过,很简单的一个程序,出现如下
错误:
- Starting E:\test\bin\app.exe...
- QWidget::create: Failed to create window ()
- Error - RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly
- RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly
代码如下:
main.cpp
- #include <QtGui/QApplication>
- #include "mainwindow.h"
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- MainWindow w;
- w.show();
- return a.exec();
- }
mainwindow.h:
- #ifndef MAINWINDOW_H
- #define MAINWINDOW_H
- #include <QMainWindow>
- #include <QTimer>
- #include "screen.h"
- namespace Ui {
- class MainWindow;
- }
- class MainWindow : public QMainWindow
- {
- Q_OBJECT
- public:
- explicit MainWindow(QWidget *parent = 0);
- ~MainWindow();
- private:
- Ui::MainWindow *ui;
- Screen *screen;
- QTimer *_timer;
- };
- #endif // MAINWINDOW_H
mainwindow.cpp:
- #include "mainwindow.h"
- #include "ui_mainwindow.h"
- MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent, Qt::FramelessWindowHint),
- ui(new Ui::MainWindow)
- {
- ui->setupUi(this);
- screen = new Screen(this); // 造了一个screen,继承自QFrame
- //_timer = new QTimer(this);
- }
- MainWindow::~MainWindow()
- {
- delete ui;
- }
做如下测试:
1. 屏蔽掉_timer的构建,clean工程能正常
编译通过,并正常运行
显示; ------ 此步OK!
2. 打开_timer的构建,直接运行程序,程序段错误,出现如下错误 --------
Error!Starting E:\test\bin\app.exe... QWidget::create: Failed to create window () Error - RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directlyRtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly 3. 对整个工程进行clean(此时_timer的构建未屏蔽),再编译运行,程序正常显示;
代码本身并未发现任何“未初始化”错误,请问如上错误如何解释?
单纯clean下工程倒能绕过错误,但每次new个新对象,就得clean次那是相当繁琐。