Reputation: 95
I'am trying to make a new QtQuick 2.0 Gui for an existing C++ project. The old QtGui was managed by a class, so i want to manage the new gui from this class too. So far i opened the gui inside of the main function, but when I move the code to my gui class everything it produces is a small white window. Is there a solution for my problem / where am I wrong?
Here is my code:
#include <QQuickView>
#include <QObject>
#include <QQuickItem>
#include "gui.h"
#include "qtquick2applicationviewer.h"
gui::gui(QWidget *parent) :
QWidget(parent)
{
QQuickView viewer;
viewer.setSource(QUrl::fromLocalFile("qml/QML-MRGalleyServer/main.qml"));
viewer.show();
QQuickItem* object = viewer.rootObject();
object->setProperty("nextpicture1","Images/widget2.png");
object->setProperty("nextpicture2","Images/widget7.png");
object->setProperty("galleyColor","transparent");
}
main.cpp:
#include <QApplication>
#include <QtCore>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "qtquick2applicationviewer.h"
#include "gui.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
gui gui;
gui.show();
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
return app.exec();
}
Upvotes: 2
Views: 2257
Reputation: 95
Ah, I solved the problem by myself. I had to initiate the QQuickView in the header. gui.h: private: QQuickView* viewer; gui.cpp: viewer = new QQuickView; The white window was caused by gui.show(), so I removed it.
Upvotes: 1