한국어
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 86180
179 z-order 를 컨트롤 하기위한 방법 makersweb 2015.05.13 6594
178 Qml 사용자 ScrollBar 구현 file makersweb 2015.07.24 6234
177 QQuickImageProvider 를 이용한 Qml 에서 이미지 표시 makersweb 2015.10.18 6008
176 Qt의 시그널 슬롯 시스템 file makersweb 2015.10.20 23674
175 Qt의 스레드간 시그널 슬롯의 커넥션타입 [1] makersweb 2015.10.24 10218
174 Qt 프로그래밍의 시작 makersweb 2015.10.25 14408
173 QtConcurrent를 이용하여 쓰레드를 만드는 방법과 MapReduce file makersweb 2016.01.24 9481
172 Ubuntu Linux에서 Qt Creator 설치 file makersweb 2016.03.06 10682
171 멀티 스레드환경, 스레드에 안전한 이벤트처리 makersweb 2016.10.27 5050
170 QString 문자열에서 숫자만 추출해서 QString으로 반환 makersweb 2017.01.10 3078
169 Qt Logging Rule, Qt 프레임워크 로그 출력 makersweb 2017.01.13 3713
168 타임스탬프( timestamp) 유닉스 시간 makersweb 2017.10.19 1627
167 QPA 플러그인과 EGLFS file makersweb 2017.11.21 3941
166 QML에서 undefined를 확인하는 방법 makersweb 2017.11.29 1489
165 임의의 메모리 영역(QImage)에 QPainter를 이용하여 그리기 file makersweb 2017.12.19 3462
164 QPA 플러그인과 HTML5 Backend file makersweb 2017.12.27 809
163 Qt 3D Studio 시작하기 file makersweb 2018.01.11 3830
162 Qt 어플리에이션 전역에 폰트 설정 makersweb 2018.01.24 5627
161 다국어 지원 어플리케이션 개발 file makersweb 2018.01.27 2986
160 Windows환경에서 mingw로 Qt 5.10 정적(static)빌드 file makersweb 2018.02.01 5709