我有多个QML文件.我只是想把它们联系起来.然后我想从我浏览的每个页面返回到我的主页.我在每个页面都使用加载器这是我的代码.
import QtQuick 1.1
Rectangle{
id:welcome
width:480
height:272
Loader{
id:loader
focus:false
anchors.fill: parent
}
gradient: Gradient {
GradientStop { position: 0.0; color: "light blue" }
GradientStop { position: 1.0; color: "blue" }
}
Text{
text:"\n\t\tPRESS ENTER"
font.bold:true
font.pointSize: 17
}
Button {
id: wel
height:30;
x:parent.width/2-30
y:parent.height/2-30
focus:true
border.color:"black"
opacity: activeFocus ? 1.0 : 0.5
Text{
text:"WELCOME"
anchors.horizontalCenter:wel.horizontalCenter;
anchors.verticalCenter:wel.verticalCenter;
}
Keys.onReturnPressed: {
wel.focus=false
loader.focus=true;
anchors.fill=parent
loader.source="Home.qml";
//welcome.visible=false;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是每当我点击按钮加载新文件.但是欢迎页面不会出现.两个文件都将重叠.当我做了visible = false时,完整的UI将会出现.我得到一个白色的屏幕.任何人都可以帮我解决这个问题吗?如何加载其他文件?
我正在尝试创建一个新的线程gpsthread,它应该在后台运行,并存储该值.
class gpsthread: public QThread{
Q_OBJECT
private:nrega_status_t status2;
public:
explicit gpsthread(QObject *parent = 0):QThread(parent) {
// QTimer *t = new QTimer(this);
// connect(t, SIGNAL(timeout()), this, SLOT(processgps()));
// t->start(10000);
}
void run(){
qDebug()<<"inside gps thread\n";
QTimer *t = new QTimer(this);
connect(t, SIGNAL(timeout()), this, SLOT(processgps()));
t->start(10000);
}
public slots:void processgps(){
int status2;
status2=gps_management();
}
};
Run Code Online (Sandbox Code Playgroud)
我的主要课程是quickview.
int main(int argc, char *argv[])
{
QString file = "qml/main.qml";
QApplication app(argc, argv);
TranslationTest myObj;
QuickView view;
subthread object;
gpsthread obj;
gprsthread gprs;
view.rootContext()->setContextProperty("rootItem", (QObject *)&myObj); …Run Code Online (Sandbox Code Playgroud) 我有一个jointjs演示代码,它在纸上有基本形状,我想增加形状的大小,或突出指针上的形状点击或光标在形状上移动,
示例演示代码在这里
var graph = new joint.dia.Graph;
var paper = new joint.dia.Paper({
el: $('#paper'),
width: 650,
height: 400,
gridSize: 20,
model: graph
});
var rb = new joint.shapes.basic.Rect({
position: { x: 50, y: 50 },
size: { width: 100, height: 40 },
attrs: { text: { text: 'basic.Rect' } }
});
graph.addCell(rb);
var tb = new joint.shapes.basic.Text({
position: { x: 170, y: 50 },
size: { width: 100, height: 30 },
attrs: { text: { text: 'basic.Text' } }
}); …Run Code Online (Sandbox Code Playgroud)