当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 3 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : [求助]QML FocusScope 的 activeFocus 条件没有生效
帖子发表于 : 2012-08-31 19:11 
头像

注册: 2009-02-09 16:11
帖子: 41
送出感谢: 0 次
接收感谢: 1
使用 QML 写的一个 TextEntry,希望在获得焦点时,边框的宽度和颜色发生变化,但是在测试的时候发现TextEntry获取到焦点之后,边框和背景均没有发生变化,请问是否 QML 写的有误?或者系统、QT的什么配置可能导致这个问题-.-

代码:
    import QtQuick 1.1
    FocusScope {
        id: focusScope
        width: 200;
        height: 36
        property alias text: textInput.text
        property alias echoMode: textInput.echoMode
        property alias validator: textInput.validator
        Rectangle {
            id: container
            width: parent.width
            height: parent.height
            anchors.fill: parent
            color: parent.activeFocus ? "#ffffff" : "#e6e1e1"
            border.width: parent.activeFocus ? 2 : 1
            border.color: parent.activeFocus ? "blue": "gray"
            radius: 6
        }
        TextInput {
            id: textInput
            font.pointSize: 12
            anchors.rightMargin: 10
            anchors.leftMargin: 10
            anchors.bottomMargin: parent.height / 6
            anchors.topMargin: parent.height / 6
            anchors.fill: parent
            focus: true
            selectByMouse: true
            smooth: true
        }
        MouseArea {
            id: mouseArea
            anchors.fill: parent
            hoverEnabled: true
            onClicked: parent.focus = true
        }
    }


我的环境是 Fedora 17, QT 4.8


页首
 用户资料  
 
2 楼 
 文章标题 : Re: [求助]QML FocusScope 的 activeFocus 条件没有生效
帖子发表于 : 2012-09-07 15:43 
头像

注册: 2010-02-21 16:19
帖子: 434
地址: 大连
送出感谢: 1
接收感谢: 2
这个不大懂,
摘抄官方文档上的一段话过来。
地址:http://qt-project.org/doc/qt-4.8/qdeclarativeintroduction.html#attached-properties

引用:
Attached Properties

Some objects attach properties to another object. Attached Properties are of the form Type.property where Type is the type of the element that attaches property.

For example, the ListView element attaches the ListView.isCurrentItem property to each delegate it creates:

Component {
id: myDelegate
Text {
text: "Hello"
color: ListView.isCurrentItem ? "red" : "blue"
}
}

ListView {
delegate: myDelegate
}

Another example of attached properties is the Keys element which attaches properties for handling key presses to any visual Item, for example:

Item {
focus: true
Keys.onSelectPressed: console.log("Selected")
}


_________________
大连Linux User Group: http://groups.google.com/group/dalian-lug?hl=zh-CN


页首
 用户资料  
 
3 楼 
 文章标题 : Re: [求助]QML FocusScope 的 activeFocus 条件没有生效
帖子发表于 : 2012-09-09 14:47 
头像

注册: 2009-02-09 16:11
帖子: 41
送出感谢: 0 次
接收感谢: 1
lexdene 写道:
这个不大懂,
摘抄官方文档上的一段话过来。
地址:http://qt-project.org/doc/qt-4.8/qdeclarativeintroduction.html#attached-properties

引用:
Attached Properties

Some objects attach properties to another object. Attached Properties are of the form Type.property where Type is the type of the element that attaches property.

For example, the ListView element attaches the ListView.isCurrentItem property to each delegate it creates:

Component {
id: myDelegate
Text {
text: "Hello"
color: ListView.isCurrentItem ? "red" : "blue"
}
}

ListView {
delegate: myDelegate
}

Another example of attached properties is the Keys element which attaches properties for handling key presses to any visual Item, for example:

Item {
focus: true
Keys.onSelectPressed: console.log("Selected")
}

多谢关注,我想这个问题应该是一些bug所致,同样的代码在windows下是完全正常的。


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 3 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 0 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译