我正在使用Qt5.9.1。当我尝试从另一个qml文件打开抽屉时出现错误
QML抽屉:在
中找不到任何打开弹出窗口的窗口
我的抽屉在drawerBottom.qml中,我想使用qml函数调用从tablePage.qml打开它。这是我的代码......
DrawerBottom.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts1.3
import QtQuick.Window 2.3
import QtQuick.Dialogs 1.2
import Qt.labs.settings 1.0
Item {
id: itemDrawerBottom
Settings {
id: settingBtm
property string style: "Default"
}
Drawer{
id: drawerBottom
Flickable{
width: 1338
height: 142
anchors.rightMargin: 8
anchors.leftMargin: 13
anchors.topMargin: 15
anchors.bottomMargin: 0
id: flickable
clip: true
anchors.fill: parent
contentWidth: flickable.width ;
contentHeight: flickable.height*1.2;
Grid {
id: gridBottom
anchors.rightMargin: 9
anchors.bottomMargin: 10
anchors.fill: parent
anchors.leftMargin: 21
anchors.topMargin: 10
columns: 2
spacing: 20
flow: Grid.LeftToRight
Component{
id: componentDrawer
Button{
id:tBtnBottom1
implicitWidth: 130
implicitHeight: 35
}
}
}
}
ScrollIndicator.vertical: ScrollIndicator { }
}
function draweropen(){
drawerbottom.open()
} }
和tablePage.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import QtQuick.Window 2.3
import QtQuick.Dialogs 1.2
import Qt.labs.settings 1.0
Item {
id: itemtable
property Item itemDrawerBottom:DrawerBottom {}
Button {
id: button41
x: 159
y: 503
width: 20
height: 20
onClicked:{
itemDrawerBottom.draweropen()
}
}
}
,我使用mail.qml
中的应用程序窗口import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import QtQuick.Window 2.3
import QtQuick.Dialogs 1.2
import Qt.labs.settings 1.0
ApplicationWindow {
id:mainwindow
visible: true
width:Screen.width
height: Screen.height
title: qsTr("E-eatZ")
GridLayout {
id: gridLayouttableview
x: 1048
y: 168
width: 529
height: 592
TablePage{
}
ColumnLayout {
id: columnLayout1DrawerBottom
x: -373
y: 412
width: 50
height: 348
DrawerBottom{
}
}
}
}