Qt 5.12 Enter the Chinese have a problem using the TextInput

qml familiar about, going to input text and interact with the background when the default text input method found not to switch Chinese input method, because I win10 system input settings to default English, other program input box, press shift to switch input method, but I wrote qt program will not work, compared what else can enter the Chinese qt program, found the problem qml file reference

I wrote qml source file is set referenced by QQuickWidget

mainWindow::mainWindow(QWidget *parent)
    : QWidget(parent)
{ 
    m_contentView = new QQuickWidget();
    m_contentView->setSource(QUrl("qrc:///Qml/mainWindow.qml")); //设置对应的qml文件

    // qml对应的widget添加到本窗口
    QVBoxLayout *layout = new QVBoxLayout;
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    layout->addWidget(m_contentView);
    setLayout(layout);
}

Change

mainWindow::mainWindow(QWidget *parent)
    : QWidget(parent)
{
    this->resize(1000, 600);

    m_contentView = new QQuickView();
    m_contentView->setSource(QUrl("qrc:///Qml/mainWindow.qml")); 

    QWidget *pViewContainer = this->createWindowContainer(m_contentView, this);
    pViewContainer->resize(size());
}

mainWindow inherited from QWidget, you can not change, but QQuickView need to manually delete, or else after clicking the close button, the program will stay blocked.

Then mainWindow.qml in TextField controls can be directly input Chinese characters by shift

Published 275 original articles · won praise 46 · views 280 000 +

Guess you like

Origin blog.csdn.net/youyudexiaowangzi/article/details/103592622