Qt5 COM Interface ITextInputPanel in windows doesn't work while fine in Qt4.7 (Touch Event)



  • Hello,
    'm using the COM Interface ITextInputPanel (windows) in Qt4 (4.7.4) to display the OS Virtual Keyboard on touch event and it works fine.
    But when I use Qt5 (5.3.2), windows refuse to display the keyboard.

    Here the code.

    MyDlg.h :

    @
    class CMyDlg : public QDialog
    {
    Q_OBJECT
    protected:

    ITextInputPanel* m_piTextInputPanel;
    QLineEdit* m_pLineEdit;

    public:
    CDlgSelConfig(QWidget* parent = NULL);
    ~CDlgSelConfig();

    virtual bool eventFilter(QObject *obj, QEvent *event);

    protected slots:
    void OnAccepted();

    protected:
    void _SetupUI();
    };
    @

    @
    CMyDlg::CMyDlg(QWidget* parent)
    : QDialog(parent)
    , m_piTextInputPanel(nullptr)
    , m_pLineEdit(nullptr)
    {
    _SetupUI();
    }

    //--------------------------------------------------------------
    CMyDlg::~CMyDlg()
    {
    if (m_piTextInputPanel != nullptr)
    m_piTextInputPanel->Release();
    }

    //--------------------------------------------------------------
    void CMyDlg::_SetupUI()
    {
    // cree la fentre
    setObjectName(QString::fromUtf8("DlgSelConfig"));
    resize(400, 311);
    setMinimumSize(QSize(400, 100));
    setWindowFlags(windowFlags()&(~Qt::WindowContextHelpButtonHint));

    setWindowTitle(DLLRES_sLoadQString(IDS_CW_TITRE_SELPARAMETRAGE));

    QGridLayout* pGridLayout=new QGridLayout(this);
    QVBoxLayout* pVerticalLayout=new QVBoxLayout();

    if( SUCCEEDED(CoCreateInstance( CLSID_TextInputPanel, nullptr, CLSCTX_INPROC, IID_ITextInputPanel, (void **) &m_piTextInputPanel)))
    {

    m_pLineEdit = new QLineEdit(this);
    pVerticalLayout->addWidget(m_pLineEdit);

    m_pLineEdit->installEventFilter(this);
    m_pLineEdit->setAttribute(Qt::WA_NativeWindow);
    m_pLineEdit->setAttribute(Qt::WA_AcceptTouchEvents);

    HWND hWnd = (HWND)m_pLineEdit->winId();

    //Attach the windows
    XDBG(HRESULT hr = )m_piTextInputPanel->put_AttachedEditWindow(hWnd);
    XASSERT(SUCCEEDED(hr));

    XDBG(hr = )m_piTextInputPanel->put_InPlaceVisibleOnFocus(FALSE);
    XASSERT(SUCCEEDED(hr));

    XDBG(hr = )m_piTextInputPanel->put_DefaultInPlaceState(InPlaceState_Expanded);
    XASSERT(SUCCEEDED(hr));
    }
    QObject::connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
    QObject::connect(pButtonBox, SIGNAL(accepted()), this, SLOT(OnAccepted()));
    }

    //--------------------------------------------------------------
    void CDlgSelConfig::OnAccepted()
    {
    done(QDialog::Accepted);
    }

    //-------------------------------------------------------------------
    bool CDlgSelConfig::eventFilter(QObject *pclSrc, QEvent *pclEvent)
    {
    if ((pclEvent->type()==QEvent::TouchBegin) && (pclSrc==m_pLineEdit))
    {

    XDBG(HRESULT hr = )m_piTextInputPanel->SetInPlaceVisibility(TRUE);
    //hr=E_FAIL in Qt 5.3.2
    }

    return __super::eventFilter(pclSrc, pclEvent);
    }
    @

    Any idea why ?

    Thank you in advance.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.