Problem description
The qvtkwidget control is used in QT’s interface. When clicking the close button in the upper right corner of the window, an error is reported: wglmakecurrent failed in makecurrent(), error: the handle is invalid
.
Solution:
By overriding the void closeevent (qcloseevent * event)
function, manually delete all qvtkwidget type controls, and then close the window.
Example
The qvtkwidget type controls in the QT design interface are as follows:
mymainwindow. H
class MyMainWindow : public QMainWindow
{
Q_OBJECT
public:
MyMainWindow(QWidget *parent = Q_NULLPTR);
protected:
void closeEvent(QCloseEvent *event);
private:
Ui::MainWindow ui;
};
mymainwindow.cpp
MyMainWindow::MyMainWindow(QWidget *parent): QMainWindow(parent)
{
ui.setupUi(this);
}
void MyMainWindow::closeEvent(QCloseEvent *event) {
delete ui.qvtkWidget;
delete ui.qvtkWidget_2;
delete ui.qvtkWidget_3;
delete ui.qvtkWidget_4;
event->accept();
}
Postscript
I don’t know whether such hasty delete processing will cause other problems. I hope you can make more corrections.
Read More:
- PCL 1.8.1 VTK 9.0 QT 5.14.9 [How to Solve]
- QT solves error: use of deleted function and is private within this context
- [Solved] Qt Error: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
- Qt Error: Debug Assertion Failed [How to Solve]
- [Solved] Tensorflow Error: failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
- [Solved] HTML report error, httprunner 3. X HTML report error, oserror: [winerror 6] handle invalid (resolved)
- How to Solve vtk error (vtkInteractorStyleSwitchBase & vtkWin32OpenGLRenderWin Error)
- [Solved] RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`
- Qt5core.pdb is not loaded [How to Solve]
- R language learning problem solving error in output $nodeid: $operator is invalid for atomic vectors
- [Solved] QT error: the packaged exe of Enigma virtual box reports an error cannot load library qt5core.dll
- [Solved] Qt UpdateLayeredWindowIndirect failed for ptDst Error
- Tensorflow Run Error or the interface is stuck or report error: Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
- QT Error: Failed to create vertex shader [Three Methods to Fix]
- ORA-24338 statement handle not executed [How to Solve]
- [Solved] PySide2 Error: This application failed to start because no Qt platform plugin could be initialized
- [Solved] Unity Error: Got null handle from IDXGIResource::GetSharedHandle
- [Solved] lightdb oracle_fdw Error: ERROR: error connecting to Oracle: OCIEnvCreate failed to create environment handle
- CIBERSOFT $operator is invalid for atomic vectors [How to Solve]
- [Solved] HTTP Error 400. The request hostname is invalid.