import Qt 4.6
Item {
id: container
signal clicked
property string text
property bool keyUsing: false
BorderImage {
id: buttonImage
source: "images/toolbutton.sci"
width: container.width; height: container.height
}
BorderImage {
id: pressed
opacity: 0
source: "images/toolbutton.sci"
width: container.width; height: container.height
}
MouseRegion {
id: mouseRegion
anchors.fill: buttonImage
onClicked: { container.clicked(); }
}
Text {
id: btnText
color: if (container.keyUsing){ "#DDDDDD" ;} else { "#FFFFFF" ;}
anchors.centerIn: buttonImage; font.bold: true
text: container.text; style: Text.Raised; styleColor: "black"
font.pixelSize: 12
}
states: [
State {
name: "Pressed"
when: mouseRegion.pressed == true
PropertyChanges { target: pressed; opacity: 1 }
},
State {
name: "Focused"
when: container.focus == true
PropertyChanges { target: btnText; color: "#FFFFFF" }
}
]
transitions: Transition {
ColorAnimation { target: btnText; }
}
width: (btnText.width + 20)
}
* This source code was highlighted with Source Code Highlighter .
...
Button {
id: tagsBtn
anchors.right: parent.right;
anchors.rightMargin: 5;
y: 1;
height: (parent.height - 3)
text: " "
}
...
* This source code was highlighted with Source Code Highlighter .
import Qt 4.6
XmlListModel {
property string tags : ""
source: "http://api.flickr.com/services/feeds/photos_public.gne?" +(tags ? "tags=" +tags+ "&" : "" )+ "format=rss2"
query: "/rss/channel/item"
namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
XmlRole { name: "title" ; query: "title/string()" }
XmlRole { name: "imagePath" ; query: "media:thumbnail/@url/string()" }
XmlRole { name: "url" ; query: "media:content/@url/string()" }
XmlRole { name: "description" ; query: "description/string()" }
XmlRole { name: "tags" ; query: "media:category/string()" }
XmlRole { name: "photoWidth" ; query: "media:content/@width/string()" }
XmlRole { name: "photoHeight" ; query: "media:content/@height/string()" }
XmlRole { name: "photoType" ; query: "media:content/@type/string()" }
XmlRole { name: "photoAuthor" ; query: "author/string()" }
XmlRole { name: "photoDate" ; query: "pubDate/string()" }
}
* This source code was highlighted with Source Code Highlighter .
import Qt 4.6
Component {
Item {
id: wrapper;
width: parent.width;
height: (avatar.y + avatar.height + 15)
Rectangle {
color: "black"
opacity: index % 2 ? 0.2 : 0.3
height: wrapper.height
width: wrapper.width
y: 1
}
Rectangle {
id: avatarBorder
width: (avatar.width + 2); height: (avatar.height + 2);
color: "transparent" ;
smooth: true
Image {
id: avatar
width: 32; height: 32
source: imagePath
anchors.centerIn: parent
}
anchors.left: wrapper.left
anchors.leftMargin: 5
anchors.verticalCenter: parent.verticalCenter
}
Text {
text: name
color: "white"
font.bold: true
style: "Raised" ; styleColor: "black"
anchors.left: avatarBorder.right
anchors.leftMargin: 10
anchors.top: avatarBorder.top
}
Text {
text: type
color: "#CCC"
font.bold: true
style: "Raised" ; styleColor: "black"
anchors.left: avatarBorder.right
anchors.leftMargin: 10
anchors.bottom: avatarBorder.bottom
}
}
}
* This source code was highlighted with Source Code Highlighter .
...
RssModel {
id: rssModel
}
ListModel {
id: proxyModel
}
ListDelegate {
id: listDelegate
}
ListView {
id: contactListView;
z: 0
model: contactlistModel; delegate : listDelegate;
highlight : highlight;highlightFollowsCurrentItem: true
focus: true
width: parent.width;
cacheBuffer: 100;
anchors.top: topToolBar.bottom
anchors.bottom: searchBar.top
}
...
* This source code was highlighted with Source Code Highlighter .
Component {
id: highlight
Rectangle {
width: contactListView.currentItem.width
height: contactListView.currentItem.height
color: "white" ; radius: 5; opacity: 0.3
y: SpringFollow {
source: contactListView.currentItem.y
spring: 3
damping: 0.2
}
}
}
* This source code was highlighted with Source Code Highlighter .
ListModel {
id: MyListElementsModel
ListElement {
name: "Polly"
type: "Parrot"
imagePath: "images/avatar.png"
age: 12
size: "Small"
}
...
* This source code was highlighted with Source Code Highlighter .
onConfirmed: {
proxyModel.clear();
for ( var i=0;i!=contactlistModel.count;i++) {
var item = contactlistModel.get(i);
if (item.name.search(searchBar.text) != -1) {
proxyModel.append({ "name" : item.name, "type" : item.type, "imagePath" : item.imagePath});
}
}
contactListView.model = proxyModel;
}
onCancelled: {
contactListView.model = contactlistModel;
}
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/81549/
All Articles