qml android 适应屏幕,QML适合所有分辨率的屏幕

大家好,我的QML代码有问题 . 我犯了错误,我把一定的大小放到了元素上,现在我把app放在其他设备上时遇到了问题 . 我会将我的代码粘贴到我有宽度和高度的位置,以便您可以更改它以向我展示如何使用动态调整大小 .

我需要说我用这段代码从qt调用qml文件:

QDeclarativeView *view= new QDeclarativeView;

ui->setupUi(this);

setCentralWidget(view);

QDeclarativeContext *ctxt = view->rootContext();

ctxt->setContextProperty("funkcije",this);

ctxt->setContextProperty("myModel", QVariant::fromValue(MainWindow::dataList));

view->setSource(QUrl("qrc:/gui.qml"));

view->setResizeMode(QDeclarativeView::SizeRootObjectToView);

showFullScreen();

这是我的QML代码:

Rectangle {

id:window

width: 602

height: 1000

anchors.fill: parent

radius: 0

.....

ListView {

id: listview1

x: 0

y: 219

// width: 574

// height: 967

width: window.width

height: window.height

visible: true

keyNavigationWraps: false

boundsBehavior: Flickable.DragAndOvershootBounds

opacity: 1

maximumFlickVelocity: 2500

anchors.leftMargin: 0

highlightMoveSpeed: 489

contentWidth: 0

preferredHighlightEnd: 2

spacing: 5

highlightRangeMode: ListView.NoHighlightRange

snapMode: ListView.SnapToItem

anchors.bottomMargin: 0

anchors.rightMargin: 0

anchors.topMargin: 219

anchors.fill: parent

model: myModel

delegate:Component {

//id: contactDelegate

Item {

id:it;

property variant myData: model

width: 574; height: 220

Column {

id:col

x: 12

y: 0

width: 561

height: 164

smooth: true

anchors.rightMargin: 0

anchors.bottomMargin: 7

anchors.leftMargin: 13

anchors.topMargin: 7

anchors.fill:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值