首页| 论坛| 消息

标题:外部文件动态加载的组件,只能通过connections连接信号吗?
作者:石头轩
日期:2015-09-14 11:09
内容:

我通过外部文件动态加载了组件,可是通过connect方式连接信号和槽函数的时候,始终提示方法未定义。还请各位大侠支招哪。代码如下:
import QtQuick 2.4import QtQuick.Window 2.2import QtQuick.Controls 1.2;import QtQuick.Controls.Styles 1.2Window {width:520;height: 440;visible: trueRectangle{width:320;height: 240;color:"#EEEEEE";id:rootItem;property var colorPickerShow: false;Text{id:coloredText;anchors.horizontalCenter: parent.horizontalCenter;anchors.top: parent.top;&nbsp ..


#1 [石头轩 09-14 11:24]
么办法了,我只好吧信号与槽函数的实现放在Connections中实现了。代码如下:
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.2;
import QtQuick.Controls.Styles 1.2
Window {
width:520;
height: 440;
visible: true
Rectangle{
width:320;
height: 240;
color:"#EEEEEE";
id:rootItem;
property var colorPickerShow: false;
Text{
id:coloredText;
anchors.horizontalCenter: parent.horizontalCenter;
anchors.top: parent.top;
anchors.topMargin: 4;
text: "hello QT";
font.pixelSize: 32;
}
Button{
id:ctrlButton;
text:"show";
anchors.left: parent.left;
anchors.leftMargin: 4;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 4;
onClicked: {
if(rootItem.colorPickerShow)
{
redLoader.sourceComponent=undefined;
blueLoader.source="";
rootItem.colorPickerShow=false;
ctrlButton.text="show";
..

回复 发表
主题 版块