• 6405阅读
  • 0回复

[提问]QWidget::create: Failed to create window ()     RtlWerpReportException 错误 [复制链接]

上一主题 下一主题
离线rockyluo
 

只看楼主 倒序阅读 楼主  发表于: 2012-11-23
最近做项目,开始做就卡了壳,以前从来没碰到过,很简单的一个程序,出现如下错误
  1. Starting E:\test\bin\app.exe...
  2. QWidget::create: Failed to create window ()
  3. Error - RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly
  4. RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly

代码如下:
main.cpp
  1. #include <QtGui/QApplication>
  2. #include "mainwindow.h"
  3. int main(int argc, char *argv[])
  4. {
  5.     QApplication a(argc, argv);
  6.     MainWindow w;
  7.     w.show();
  8.     return a.exec();
  9. }

mainwindow.h:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include <QTimer>
  5. #include "screen.h"
  6. namespace Ui {
  7.     class MainWindow;
  8. }
  9. class MainWindow : public QMainWindow
  10. {
  11.     Q_OBJECT
  12. public:
  13.     explicit MainWindow(QWidget *parent = 0);
  14.     ~MainWindow();
  15. private:
  16.     Ui::MainWindow *ui;
  17.     Screen *screen;
  18.     QTimer *_timer;
  19. };
  20. #endif // MAINWINDOW_H

mainwindow.cpp:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. MainWindow::MainWindow(QWidget *parent) :
  4.     QMainWindow(parent, Qt::FramelessWindowHint),
  5.     ui(new Ui::MainWindow)
  6. {
  7.     ui->setupUi(this);
  8.     screen = new Screen(this);      // 造了一个screen,继承自QFrame
  9.     //_timer = new QTimer(this);
  10. }
  11. MainWindow::~MainWindow()
  12. {
  13.     delete ui;
  14. }

做如下测试:
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 directly
RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly

3. 对整个工程进行clean(此时_timer的构建未屏蔽),再编译运行,程序正常显示;  

代码本身并未发现任何“未初始化”错误,请问如上错误如何解释?
单纯clean下工程倒能绕过错误,但每次new个新对象,就得clean次那是相当繁琐。



                                                                                                              我们要团结一心,秉承Linux的开源精神,共享Qt问题的解决方法!
快速回复
限100 字节
 
上一个 下一个