Qt在QWidget :: update()

时间:2018-06-15 11:54:57

标签: c++ qt crash

我有一个简单的程序,可以从相机中读取图像并将其转换为Qimage。然后将其转换为像素图,该像素图应该在paintEvent(QPaintEvent * event)

中绘制

问题是程序在绘制窗口小部件时崩溃。在离开on_pushButtonTakeImage_clicked()

的同时

这是基本代码:

void MainWindow::on_pushButtonTakeImage_clicked()
{    
  bool isReady = camera->initialize();
  if (isReady){
    camera->openCamera();
    camera->capture();
    ui->widgetCameraImage->setImage(camera->image());
  }
}

void QCameraImageBase::setImage(const QImage & image)
{
    Q_D(QCameraImageBase);

    d->pixmap = QPixmap::fromImage(image);
    update(); // calls paintEvent
}

永远不会调用重载paintEvent(QPaintEvent * event)中的调试点。

这是追踪

1   ntdll!RtlQueryPerformanceCounter                                0x77603266 
2   ntdll!RtlQueryPerformanceCounter                                0x776034a1 
3   ntdll!RtlpNtEnumerateSubKey                                     0x776a10c3 
4   ntdll!RtlUlonglongByteSwap                                      0x7765abe2 
5   ??                                                              0x1a830000 
6   ntdll!RtlQueryPerformanceCounter                                0x776034a1 
7   msvcrt!malloc                                                   0x77149d45 
8   libstdc++-6!_Znwj                                               0x7c999a   
9   QRasterPaintEngine::createState    qpaintengine_raster.cpp 686  0xd5f469   
10  QPainter::begin                    qpainter.cpp            1754 0xd6f375   
11  QPainter::QPainter                 qpainter.cpp            1476 0xd6fc60   
12  QWidgetPrivate::drawWidget         qwidget.cpp             5560 0xe1a4012  
13  QWidgetBackingStore::doSync        qwidgetbackingstore.cpp 1375 0xe177a66  
14  QWidgetBackingStore::sync          qwidgetbackingstore.cpp 1156 0xe177e95  
15  QWidgetPrivate::syncBackingStore   qwidget.cpp             1951 0xe19181c  
16  QWidget::event                     qwidget.cpp             9216 0xe1ac102  
17  QMainWindow::event                 qmainwindow.cpp         1342 0xe2c8ac0  
18  QApplicationPrivate::notify_helper qapplication.cpp        3732 0xe1686de  
19  QApplication::notify               qapplication.cpp        3695 0xe172093  
20  QCoreApplication::notifyInternal2  qcoreapplication.cpp    1050 0x6bb0b5d1 
... <Mehr>                                                                     

我与Qt Creator合作并且mingw。我可以采取哪些措施来解决此错误或找到有关原因的更多信息?

0 个答案:

没有答案