한국어
Qt
 

Qt5에서 제공하는 가상키보드(Qt Virtual Keyboard)를 사용하는 방법에 대해서 설명한다. 다만 Qt Wayland환경에서 사용하는 방법은 설명하지 않으므로 자세한 내용은 다음글을 참고하면 된다.  https://doc.qt.io/qt-5/qtvirtualkeyboard-deployment-guide.html

 

가상키보드가 화면에 보여지기 위한 벙법에는 두가지가 있다.

 

데스크탑(Windows 또는 Linux/X11 환경) : 이 경우 응용프로그램을 수정 할 필요가 없이 키보드는 자체적인 최상위 창으로 보여지게된다.

 

임베디드 장치(특히 eglfs 같은 환경) : 이 경우 응용프로그램의 QML에 InputPanel 을 배치함으로써 화면에 보여진다. 멀티 윈도우를 지원하지 않는 (윈도우 시스템이 없는)환경에서는 필수이고 데스크탑 환경에서는 선택적으로 사용할 수 있다.

 

사용 방법은 플러그인 프로젝트 파일에서 자동으로 선택된다. (컴파일 시점에)

 

두 가지 방법 모두에서 응용 프로그램은 QT_IM_MODULE 환경 변수를 설정하여 플러그인을로드해야한다.

응용프로그램의 main함수에서 설정하거나

int main(int argc, char *argv[])
{
    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));

    ...
}

 

셸에서 환경변수를 설정한다.

$ QT_IM_MODULE=qtvirtualkeyboard myapp

 

데스크탑의 경우 더 이상 할게 없지만 아닌 경우는 응용프로그램의 QML에서 InputPanel을 사용하여 인스턴스화해야 한다.

import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
import QtQuick.VirtualKeyboard 2.1

Window {
    id: window
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    TextField{
        width: 250
        height: 70
        anchors.top: parent.top
        anchors.topMargin: 30
        anchors.horizontalCenter: parent.horizontalCenter
    }

    InputPanel {
        id: inputPanel
        z: 99
        x: 0
        y: window.height
        width: window.width

        states: State {
            name: "visible"
            when: inputPanel.active
            PropertyChanges {
                target: inputPanel
                y: window.height - inputPanel.height
            }
        }
        transitions: Transition {
            from: ""
            to: "visible"
            reversible: true
            ParallelAnimation {
                NumberAnimation {
                    properties: "y"
                    duration: 250
                    easing.type: Easing.InOutQuad
                }
            }
        }
    }
}

 

라즈베리파이3에서 욕토(yocto)로 빌드한 임베디드 리눅스 및 eglfs 환경으로 qtvirtualkeyboard를 사용한 화면.

qtvirtualkeyboard.png

 

번호 제목 글쓴이 날짜 조회 수
공지 Qt프로그래밍(QtQuick) Beginner를 위한 글 읽는 순서 운영자 2019.01.05 78886
71 Qt기반의 오픈소스 프로젝트들 - 2 운영자 2019.07.21 3646
70 QML, 이미지, 폰트등을 바이너리 리소스로 만들기 makersweb 2019.06.24 2919
69 Qt Creator에서 임베디드 장치로 deploy설정(Custom Process Step) file makersweb 2019.06.15 1925
68 Qt Quick Controls 2사용 및 스타일 설정 file makersweb 2019.06.07 5613
67 QML 강좌 - 동적 Listing (ListView) file makersweb 2019.06.01 8949
66 QtInstallerFramework로 온라인 설치프로그램(Online Installer)만드는 방법 [4] file makersweb 2019.05.28 1854
65 QtCreator Design으로 GUI만들기 (QML로 만드는 Hello World -2) [1] file makersweb 2019.05.26 12678
64 QML에서 멀티 스레드(multithreading) 프로그래밍 file makersweb 2019.05.25 2323
63 QtSerialPort를 사용한 시리얼(Serial)통신 [3] makersweb 2019.05.21 9822
62 Qt기반의 오픈소스 프로젝트들 makersweb 2019.05.15 4583
61 Q_D매크로와 d-pointer file makersweb 2019.05.07 662
» 가상키보드(Qt Virtual Keyboard)를 사용하는 방법 [32] file makersweb 2019.05.03 211357
59 Windows에서 Qt D-Bus를 사용하여 프로세스간 통신(IPC) file makersweb 2019.05.02 3557
58 QML과 QtQuick 모듈 개념과 기본 타입들 makersweb 2019.04.26 12325
57 QML 전역 객체 (Global Object) file makersweb 2019.04.10 908
56 tslib의 ts_calibrate를 응용해서 Qt로 터치보정기능 구현 file makersweb 2019.04.06 1128
55 GPU가 없는 장치에서 Qt Quick을 사용 makersweb 2019.04.02 1732
54 QTextCodec클래스를 사용하여 유니코드와 EUC-KR 변환 makersweb 2019.03.25 2305
53 qInstallMessageHandler를 이용한 디버그 메세지 출력 제어하기 makersweb 2019.02.25 1099
52 Qt5기반 독립 프로세스(out-of-process)로 동작하는 가상키보드(virtual keyboard) file makersweb 2019.02.24 2378