|
7Qter豆
- Mytab.qml
- import QtQuick 2.2
- import QtQuick.Controls 1.1
- import QtQuick.Layouts 1.1
- import QtWebKit 3.0
- Rectangle{
- id:tab
- width:parent.width
- height:parent.height
-
- TextArea {
- id: textArea
- text:""
- anchors.fill: parent
-
- }
- }
复制代码 main.qml- import QtQuick 2.2
- import QtQuick.Controls 1.1
- import QtQuick.Layouts 1.1
- ApplicationWindow{
- visible:true
- width:640
- height:480
- id:window
- title:"editor"
- Column{
-
- Button{
- id:getInfo
- width:100
- height:100
- text:"getinfo"
- onClicked:{
- console.log(textArea.text)
- }
-
- }
- Button{
- id:addTab
- width:100
- height:100
- text: "add tab"
- onClicked:{
- var c = Qt.createComponent("Mytab.qml");
- tabview.addTab("tab", c);
- var last = tabview.count-1;
- tabview.getTab(last).active = true;
-
- }
- }
-
-
-
-
- TabView{
- id:tabview
- //anchors.top: addTab.bottom
- visible: true
-
- Layout.fillHeight: true
- Layout.fillWidth: true
- }
- }
-
- }
复制代码 各位大神,我写了一个带选项卡的程序,我想在主窗口中获取选项卡中的内容,就是程序的getInfo button中获取选项卡中的text内容,怎样在main.qml中获取到Mytab.qml中的textArea ,请问我该怎么做呢?如果有完整的关于qml的多选项卡记事本的程序例子,那就更好了!
|
最佳答案
查看完整内容
在你的mytab.qml 里面这样写:其实关键只是alias当成一个指针来使用而已
|