한국어
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 86052
23 QPA 플러그인과 EGLFS file makersweb 2017.11.21 3934
22 QPA 플러그인과 HTML5 Backend file makersweb 2017.12.27 808
21 Windows에서 라즈베리파이3용 Qt5.10.0 크로스컴파일 [20] file makersweb 2018.02.23 13001
20 안드로이드 Qt 프로그래밍 file makersweb 2018.11.30 8836
19 싱글터치 스크린 및 임베디드 리눅스 기반에서 Qt 터치입력 makersweb 2018.12.24 1401
18 QtWayland와 ivi-compositor file makersweb 2018.12.27 2411
17 안드로이드 가상장치 사용 file makersweb 2019.01.13 1074
16 Qt Bluetooth를 이용한 시리얼(Serial) 통신 file makersweb 2019.02.17 3584
15 Qt5기반 독립 프로세스(out-of-process)로 동작하는 가상키보드(virtual keyboard) file makersweb 2019.02.24 2629
» 가상키보드(Qt Virtual Keyboard)를 사용하는 방법 [32] file makersweb 2019.05.03 221512
13 MCU용 Qt에 대해서 makersweb 2019.08.22 1919
12 Qt for Embedded Linux 화면출력 makersweb 2019.10.17 1601
11 라즈베리파이3에서 Boot to Qt 실행해보기 makersweb 2019.11.13 1670
10 Qt for MCU 1.0 릴리즈 makersweb 2019.12.10 752
9 라즈베리파이4에 대한 Qt 5.14.1 크로스컴파일 [1] file makersweb 2020.02.12 4452
8 Qt로 작성된 안드로이드 APP에 Splash Screen을 추가 file makersweb 2020.03.10 885
7 Qt MQTT 에 대해서 file makersweb 2020.06.02 961
6 Qt MQTT의 pus/sub 튜토리얼 file makersweb 2021.02.06 1653
5 Qt Android 앱에 AdMob 배너달기 file makersweb 2021.12.04 395
4 Qt Bluetooth Low Energy 개요 makersweb 2022.02.13 675