C++ QWidget::update()中的Qt崩溃
我有一个简单的程序,从相机中读取图像并将其转换为Qimage。然后将其转换为pixmap,该pixmap应在C++ QWidget::update()中的Qt崩溃,c++,qt,crash,C++,Qt,Crash,我有一个简单的程序,从相机中读取图像并将其转换为Qimage。然后将其转换为pixmap,该pixmap应在paintEvent(QPaintEvent*event) 问题是程序在绘制小部件时崩溃。在这里,当按下按钮将打开时,单击了图像() 这是基本代码: void MainWindow::on_pushButtonTakeImage_clicked() { bool isReady = camera->initialize(); if (isReady){ cam
paintEvent(QPaintEvent*event)
问题是程序在绘制小部件时崩溃。在这里,当按下按钮将打开时,单击了图像()
这是基本代码:
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>
1ntdll!RtlQueryPerformanceCounter 0x77603266
2个ntdll!RtlQueryPerformanceCounter 0x776034a1
3个ntdll!RTLPntenumerate子项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::事件QMainWindow.cpp 1342 0xe2c8ac0
18 QApplicationPrivate::notify_helper qapplication.cpp 3732 0xe1686de
19 QApplication::通知QApplication.cpp 3695 0xe172093
20 QCoreApplication::notifyInternal2 QCoreApplication.cpp 1050 0x6bb0b5d1
...
我与Qt Creator和mingw合作。我能做些什么来修复此错误或查找更多有关原因的信息?您需要提供一个解决方案。我的第一个猜测是,您的代码中的其他地方有未定义的行为。似乎您违反了内存堆(在堆栈中查找malloc),这不一定是由于提供的代码,而是当时发生的。