欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > Android >内容正文

Android

qt on android 桌面鼠标事件,關於Qt on Android,程序安裝到手機,界面只占到一小部分。...

发布时间:2025/3/20 Android 61 豆豆
生活随笔 收集整理的这篇文章主要介绍了 qt on android 桌面鼠标事件,關於Qt on Android,程序安裝到手機,界面只占到一小部分。... 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

環境為Qt5.7。

手機界面:

PC界面:

程序如下,手機為三星I9300,rom為CM13,6.0系統。 想知道如何占滿屏幕

main.cpp

#include 

#include 

#include 

int main(int argc, char *argv[])

{

QGuiApplication app(argc, argv);

QQuickView viewer;

viewer.setSource(QUrl("qrc:/main.qml"));

viewer.setMinimumSize(QSize(360, 480));

viewer.show();

return app.exec();

}

mian.qml

import QtQuick 2.7

import QtQuick.Window 2.2

import QtQuick.Controls 2.0

import QtQuick.Controls.Styles 1.4

import QtQuick.Dialogs 1.2

Row {

anchors.rightMargin: 0

anchors.bottomMargin: 0

anchors.leftMargin: 0

anchors.topMargin: 0

anchors.fill: parent

spacing: 20

Column {

width: 200

spacing: 16

Text {

id: sliderStat

color: "blue"

text: "current - 0.1"

}

Slider {

width: 200

height: 30

stepSize: 0.01

value: 0.1

onValueChanged: {

sliderStat.text = "current - " + value

}

}

Slider {

width: 200

height: 30

orientation: Qt.Horizontal

clip: false

visible: true

from: 0

to: 100

stepSize: 1

value: 50

}

Slider {

id: customGrooveAndHandle

width: 200

height: 30

stepSize: 0.1

value: 0

//groove: Rectangle {

//}

}

Slider {

id: control

value: 0.5

background: Rectangle {

x: control.leftPadding

y: control.topPadding + control.availableHeight / 2 - height / 2

implicitWidth: 200

implicitHeight: 4

width: control.availableWidth

height: 50//implicitHeight

radius: 2

color: "#bdbebf"

Rectangle {

width: control.visualPosition * parent.width

height: parent.height

color: "#21be2b"

radius: 2

}

}

handle: Rectangle {

x: control.leftPadding + control.visualPosition * (control.availableWidth - width)

y: control.topPadding + control.availableHeight / 2 - height / 2

implicitWidth: 10

implicitHeight: 50

radius: 10

color: control.pressed ? "#f0f0f0" : "#f6f6f6"

border.color: "#bdbebf"

}

}

Slider {

id: control1

value: 0.5

orientation: Qt.Vertical

background: Rectangle {

x: control1.leftPadding + control1.availableWidth / 2 - width / 2

y: control1.topPadding

implicitWidth: 200 //隱式的

implicitHeight: 200

width: 50

height: control1.availableHeight//50//implicitHeight

radius: 2

color: "#bdbebf"

Rectangle {

width: parent.width//control1.visualPosition * parent.width

height: control1.visualPosition * parent.height

color: "#21be2b"

radius: 2

}

}

handle: Rectangle {

x: control1.leftPadding + control1.availableWidth / 2 - width / 2

y: control1.bottomPadding + control1.visualPosition * (control1.availableHeight - height)

implicitWidth: 50

implicitHeight: 10

radius: 10

color: control1.pressed ? "#f0f0f0" : "#f6f6f6"

border.color: "#bdbebf"

}

}

}

}

2 个解决方案

#1

控件屬性設置下

#2

Qt自帶quickview的例程差不多只要設置的320*480的,打包進手機運行都 只占用手機左上角320*480,感覺好坑。請問樓主解決了嗎??

总结

以上是生活随笔为你收集整理的qt on android 桌面鼠标事件,關於Qt on Android,程序安裝到手機,界面只占到一小部分。...的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。