수행기록퀘스트6

퀘스트 6/7 - 이미지 빌드 및 QT 환경에서의 예제 실행 따라해보기
2020. 5. 28 (목) 09:26 곽병* 조회 212 좋아요 0 스크랩 0 댓글 0

이 과제를 하면서 QT가 처음이라 모르는 부분이 많아 어려웠습니다. 

 

제가 구상한것이 틀릴 수도 있지만, swipe를 사용하는 quick과  시계 예제는 위젯 형태여서 그냥 합쳐서 동작 안되었습니다. 

 

합치는 방법이 있을 수도 있지만 quick(swipe)과 widget(digital시계)와 같이 각각  혼홥된 예제가 큰 도움이 되지 않았습니다. 

 

저의 경우는 QML을 사용하여 제작 하였으며, 먼저 SWIPE와 시계 코드를 공유 드립니다. 

 

1) QTcreater에서 Welcome -> NEW -> Application (QT Quick) -> QT Quick Application -swipe를 선택합니다. 

 

 

main. qml

****************************************************************************

import QtQuick 2.11
import QtQuick.Controls 2.4


ApplicationWindow {

    visible: true
    width: 480
    height: 800
    title: qsTr("Tabs")

    property var count : 0


    SwipeView {
        id: swipeView
        anchors.fill: parent
        currentIndex: tabBar.currentIndex


        Page1Form {
            id : timepage
            property date currentDate: new Date()


            function timeChanged() {
                    currentDate = new Date()
                    textField1.text = Qt.formatTime(currentDate, "hh:mm:ss");

                }

                Timer {
                    interval: 1000; running: true; repeat: true;
                    onTriggered: timepage.timeChanged()
                }
        }

        Page2Form {
        }
    }

    footer: TabBar {
        id: tabBar
        currentIndex: swipeView.currentIndex

        TabButton {
            text: qsTr("Clock")
        }
        TabButton {
            text: qsTr("Timer")
        }
    }
}

****************************************************************************

 

page1Form.ui.qml

**************************************************************************

import QtQuick 2.11
import QtQuick.Controls 2.4

Page {

property alias textField1: textField1

    id: page
    width: 480
    height: 800

        TextField {
            id: textField1
            x: 0
            width: 480
            height: 75
            font.kerning: false
            font.preferShaping: false
            padding: 10
            font.pointSize: 42
            horizontalAlignment: Text.AlignRight
            anchors.top: parent.top
            anchors.topMargin: 318
            placeholderText: qsTr("00:00:00")
        }


}

**************************************************************************

 

로그인 후
참가 상태를 확인할 수 있습니다.