Chinaunix首页 | 论坛 | 博客
  • 博客访问: 940877
  • 博文数量: 192
  • 博客积分: 3070
  • 博客等级: 中校
  • 技术积分: 1861
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-27 23:44
个人简介

Start Linux Leave Linux a while Back to Linux

文章分类

全部博文(192)

文章存档

2023年(18)

2022年(11)

2021年(8)

2020年(14)

2019年(7)

2018年(13)

2017年(16)

2016年(4)

2012年(2)

2011年(13)

2010年(26)

2009年(13)

2008年(27)

2007年(20)

我的朋友

分类: C/C++

2017-02-25 23:39:59

一个QML界面调用另一个 qml 文件

main.qml 文件

点击(此处)折叠或打开

  1. import QtQuick 2.5
  2. import QtQuick.Window 2.2
  3. import QtQuick.Controls 1.2


  4. Window {
  5.     visible: true
  6.     width: 640
  7.     height: 480
  8.     //flags: Qt.FramelessWindowHint
  9.     title: qsTr("Hello World")

  10.     /*
  11.     MainForm {
  12.         anchors.fill: parent
  13.         mouseArea.onClicked: {
  14.             Qt.quit();
  15.         }

  16.     }
  17.   */

  18.     Test2 {id: test2window}


  19.     Button {
  20.             id: button2
  21.             x: 224
  22.             y: 145
  23.             width: 110
  24.             height: 36
  25.             text: qsTr("Show")

  26.             onClicked: {
  27.                 //Qt.quit();
  28.                 //Test2.show();
  29.                 test2window.show();
  30.             }

  31.         }


  32.     Label {
  33.         id: label1
  34.         anchors{
  35.             left: parent.left;
  36.             leftMargin: 30
  37.             top: parent.top
  38.             topMargin: 50
  39.         }
  40.         font.pixelSize: 16
  41.         text: "Name"
  42.     }
  43. }
Test2.qml 文件

点击(此处)折叠或打开

  1. import QtQuick 2.5
  2. import QtQuick.Window 2.2
  3. import QtQuick.Controls 1.2

  4. Window {
  5.     id: test2window
  6.     width: 640
  7.     height: 480
  8.     flags: Qt.FramelessWindowHint

  9.     Button {
  10.             id: button2
  11.             x: 224
  12.             y: 145
  13.             width: 110
  14.             height: 36
  15.             text: qsTr("Second Frame")

  16.             onClicked: {
  17.                 close();
  18.             }

  19.         }
  20. }

工程目录




阅读(1109) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~