Experiment with Qt Quick 2 controls.

This commit is contained in:
Dorian 2018-08-15 17:06:32 -04:00
parent 2bb6ae818e
commit d152eb52d7
6 changed files with 36 additions and 7 deletions

View File

@ -1,5 +1,7 @@
import QtQuick 2.0 import QtQuick 2.0
import QtMultimedia 5.8 import QtMultimedia 5.8
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
@ -43,12 +45,12 @@ Rectangle {
MenuButton { MenuButton {
buttonText: "Open Game" buttonText: "Open Game"
// disabled: true enabled: false
} }
MenuButton { MenuButton {
buttonText: "Save Game" buttonText: "Save Game"
// disabled: true enabled: false
function actionOnClick() { function actionOnClick() {
pingSound.seek(0) pingSound.seek(0)
pingSound.play() pingSound.play()
@ -70,6 +72,15 @@ Rectangle {
buttonText: "Settings" buttonText: "Settings"
} }
Button {
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 50
height: parent.parent.height * 0.1
text: "Quit"
onPressed: Qt.quit()
Material.accent: Material.Orange
}
MenuButton { MenuButton {
buttonText: "Quit" buttonText: "Quit"
function actionOnClick() { function actionOnClick() {

View File

@ -6,8 +6,8 @@ Rectangle {
property color backgroundAtRest: "#9e9e9e" property color backgroundAtRest: "#9e9e9e"
property color backgroundActive: "#555555" property color backgroundActive: "#555555"
property string buttonText: "Button" property string buttonText: "Button"
property bool enabled: true
function actionOnClick() { } function actionOnClick() { }
@ -17,7 +17,12 @@ Rectangle {
height: parent.parent.height * 0.1 height: parent.parent.height * 0.1
radius: 10 radius: 10
color: backgroundAtRest color: {
if (enabled)
backgroundActive
else
backgroundAtRest
}
border.color: "#333333" border.color: "#333333"
border.width: 2 border.width: 2

View File

@ -1,4 +1,4 @@
QT += quick multimedia multimediawidgets QT += quick multimedia multimediawidgets svg quickcontrols2
CONFIG += c++11 CONFIG += c++11
# The following define makes your compiler emit warnings if you use # The following define makes your compiler emit warnings if you use
@ -22,6 +22,8 @@ QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer # Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH = QML_DESIGNER_IMPORT_PATH =
QT_QUICK_CONTROLS_STYLE=universal
# Default rules for deployment. # Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin

View File

@ -1,7 +1,8 @@
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Window 2.2 import QtQuick.Controls 2.1
Window {
ApplicationWindow {
id: mainWindow id: mainWindow
property var appVersion: "0.4.0" property var appVersion: "0.4.0"

View File

@ -16,5 +16,6 @@
<file>images/splash.jpg</file> <file>images/splash.jpg</file>
<file>MenuButton.qml</file> <file>MenuButton.qml</file>
<file>assets/ping.wav</file> <file>assets/ping.wav</file>
<file>qtquickcontrols2.conf</file>
</qresource> </qresource>
</RCC> </RCC>

9
qtquickcontrols2.conf Normal file
View File

@ -0,0 +1,9 @@
[Controls]
Style=Material
[Material]
Theme=Dark
[Material\Font]
Family=Open Sans
PixelSize=32