한국어
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 86955
139 QML에서 Websocket 서버와 통신 file makersweb 2021.09.18 904
138 Qt 6의 C++ 프로퍼티 바인딩 예제 makersweb 2021.11.01 914
137 QML에서 D-Bus 통신 file makersweb 2023.03.15 927
136 Qt로 작성된 안드로이드 APP에 Splash Screen을 추가 file makersweb 2020.03.10 934
135 QML 에서 QR코드 생성 file makersweb 2021.08.20 946
134 Qt 응용프로그램에서 Lottie Animation사용 file makersweb 2021.05.30 947
133 Qt로 작성된 iOS 앱에서 시리얼 통신 file makersweb 2022.04.30 959
132 Qt 5.15 및 Qt 6의 출시 일정 makersweb 2020.04.09 973
131 QML 바인딩 끊김 진단 makersweb 2020.11.08 974
130 Qt 5 코드를 Qt 6로 포팅하기 위해 도움이 되는 Clazy Framework file makersweb 2021.03.01 995
129 Qt기반의 서버와 클라이언트간 SOAP(Simple Object Access Protocol) file makersweb 2020.05.11 1015
128 Qt 6.0의 개발 호스트 및 대상 플랫폼 makersweb 2020.09.16 1023
127 [Qt] Google Play의 향후 요구 사항을 준수하는 방법 [2] j2doll 2019.07.29 1023
126 Qt MQTT 에 대해서 file makersweb 2020.06.02 1024
125 Qt로 XML 파싱 : Qt 6에서 업데이트된 (Parsing XML with Qt: Updates for Qt 6) [1] j2doll 2020.01.16 1028
124 Qt 6에서 QList 변경사항 makersweb 2020.10.08 1055
123 QProcess 예제 (프로그램 재시작) file makersweb 2023.01.25 1077
122 QScopedPointer 소개 및 사용법 makersweb 2019.11.29 1081
121 QOpenGLWidget 을 투명하게 적용 file makersweb 2020.02.05 1117
120 QML 전역 객체 (Global Object) file makersweb 2019.04.10 1121