The program crashes after using the plug-in!!!!
Unsolved
General and Desktop
-
QT version: QT5.14.2
Environment: Windows10
Compiler: MSVC2017_64Problem description: The program has two interfaces. Interface A is MainWindow, inherited from QMainWindow, interface B is Form, inherited from QWidget, and both interfaces have QLineEdit. When using a plug-in (optional plug-in), there is no problem when entering QLineEdit on interface A. When interface B pops up from interface A, when entering QLineEdit on interface B (input by keyboard), the program will crash.
Source code:
main.cpp:#include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { // // The self-defined soft keyboard will crash when typing in interface B // qputenv("QT_IM_MODULE", QByteArray("tgtsml")); // // The system soft keyboard will also crash // qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); qputenv("QT_IM_MODULE", QByteArray("111")); QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
mainwindow.h:
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include "form.h" QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: void on_pushButton_clicked(); private: Ui::MainWindow *ui; Form *form; }; #endif // MAINWINDOW_H
mainwindow.cpp:
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { form = new Form(); form->show(); }
form.h:
#ifndef FORM_H #define FORM_H #include <QWidget> namespace Ui { class Form; } class Form : public QWidget { Q_OBJECT public: explicit Form(QWidget *parent = nullptr); ~Form(); private: Ui::Form *ui; }; #endif // FORM_H
form.cpp:
#include "form.h" #include "ui_form.h" Form::Form(QWidget *parent) : QWidget(parent), ui(new Ui::Form) { ui->setupUi(this); } Form::~Form() { delete ui; }
Because I caused a crash when I used the soft keyboard, I finally found the above problem
-