Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. The program crashes after using the plug-in!!!!

The program crashes after using the plug-in!!!!

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 282 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hedge_tp
    wrote on last edited by
    #1

    QT version: QT5.14.2
    Environment: Windows10
    Compiler: MSVC2017_64

    Problem 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

    1 Reply Last reply
    0
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by
      #2

      try form = new Form(this);
      Try to run the program in debug mode

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hedge_tp
        wrote on last edited by
        #3

        Hello, thank you for your reply. I tried, but the result is still the same

        Christian EhrlicherC 1 Reply Last reply
        0
        • H Hedge_tp

          Hello, thank you for your reply. I tried, but the result is still the same

          Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Hedge_tp Please use a debugger and see where exactly it crashes as @mrdebug already told you.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved