hello,
I wrote a very simple code by QML and run it on Windows.
In this code, I load slot1.qml in unit.qml by four times.
But I found the third one does not draw well.
Please see the below URL, where I uploaded the problem picture.
The third one from left side has the drawing problem.
http://ameblo.jp/jianghaiying2002/entry-11768624153.html
And also please see the below code.
unit.qml
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.0
Item {
width: 1200; height: 650
Rectangle {
id: rectangle1
width: 50
height: 400
color: "lightyellow"
border.color: "black"
Label {
anchors.centerIn: parent
text: "UNIT"
rotation: 90
}
}
Item {
id: slots
anchors {left: rectangle1.right; leftMargin: 10; top: rectangle1.top}
width:990
height: 300
Row{
Item{
width: (slots.width)/16; height:300
Loader{
source: "slot1.qml"
}
}
Item{
width: (slots.width)/16; height:300
}
Item{
width: (slots.width)/16; height:300
Loader{
source: "slot1.qml"
}
}
Item{
width: (slots.width)/16; height:300
}
Item{
width: (slots.width)/16; height:300
Loader{
source: "slot1.qml"
}
}
Item{
width: (slots.width)/16; height:300
}
Item{
width: (slots.width)/16; height:300
Loader{
source: "slot1.qml"
}
}
}
}
}
slot1.qml
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.0
Rectangle {
id: slot1
width: 120
height: 300
color: "#d4d4d4"
border.color: "#625a5a"
Text{
x: 26
anchors.top: parent.top
text: "slot1"
font.family: "Verdana"
anchors.topMargin: 33
}
Rectangle {
id: rectangle1
x: 53
y: 116
width: 10
height: 10
border.color: "#625b5b"
}
Rectangle {
id: rectangle2
x: 53
y: 137
width: 10
height: 10
border.color: "#625b5b"
}
Rectangle {
id: rectangle3
x: 53
y: 160
width: 10
height: 10
border.color: "#625b5b"
}
Label {
id: label1
x: 13
y: 137
width: 37
height: 10
text: "PORT1"
horizontalAlignment: Text.AlignRight
font.pointSize: 8
}
Label {
id: label2
x: 12
y: 116
width: 38
height: 10
text: "PORT2"
horizontalAlignment: Text.AlignRight
font.pointSize: 8
}
Label {
id: label3
x: 13
y: 160
width: 37
height: 10
text: "PORT3"
horizontalAlignment: Text.AlignRight
font.pointSize: 8
}
Label {
id: label4
x: 43
y: 283
text: "#1"
font.pointSize: 8
style: Text.Normal
font.family: "Verdana"
horizontalAlignment: Text.AlignHCenter
}
Rectangle {
id: rectangle4
anchors{left: parent.left; top: parent.top; margins: 10}
width: 15
height:8
radius: 15
color: "#028000"
border.color: "black"
}
}
main.cpp
#include <QtQuick/QQuickView>
#include <QGuiApplication>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:///unit.qml"));
view.show();
return app.exec();
}
Thanks!
↧