한국어
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 85893
99 Qt for MCU 1.0 릴리즈 makersweb 2019.12.10 751
98 Qt Marketplace 발표 makersweb 2019.12.02 617
97 QScopedPointer 소개 및 사용법 makersweb 2019.11.29 1027
96 QOpenVirtualkeyboard(Qt 5용 한글 및 영문, 숫자 가상키보드) file makersweb 2019.11.27 2241
95 Qt3D의 QML 타입으로 3D렌더링 file makersweb 2019.11.20 2527
94 라즈베리파이3에서 Boot to Qt 실행해보기 makersweb 2019.11.13 1668
93 Qt애플리케이션 객체(QCoreApplication, QGuiApplication, QApplication) 에 대해서 makersweb 2019.11.11 10103
92 Qt Quick 3D 소개 makersweb 2019.11.09 1444
91 QPushButton 의 커스텀 이미지버튼 file makersweb 2019.11.05 6387
90 qbs 사용 방법(Helloworld) file makersweb 2019.10.23 3094
89 웹기반 Qt Design Viewer [2] file makersweb 2019.10.23 1302
88 Qt Creator에서 Qt의존성 라이브러리 자동복사하기 file makersweb 2019.10.19 2163
87 Qt for Embedded Linux 화면출력 makersweb 2019.10.17 1599
86 Windows에서 Qt 설치 따라하기 file makersweb 2019.10.14 30877
85 Qbs 프로젝트를 정의하기 위해 사용되는 몇가지 중요한 아이템들 file makersweb 2019.10.13 296
84 많은 리소스를 사용하는 Qt프로젝트에서 고려해봐야 할 qmake 옵션 makersweb 2019.10.11 1236
83 Qbs에 대한 소개와 설치하는 방법 makersweb 2019.10.09 1369
82 OpenGL 렌더링을 QtQuick과 통합하는 방법 file makersweb 2019.10.01 2181
81 QML내에서의 시그널, 슬롯 시스템 makersweb 2019.09.29 6947
80 컨테이너에 적재된 객체를 편리하게 삭제하기 makersweb 2019.09.18 1665