Unsolved Can't assign QScreen to QML Window
-
Doing some work with Qt now, but I'm stuck trying to figure out how to apply a screen to a QML Window element.
I'm doing this in the QML file
screen: app.getMonitor(this.screen);
and this corresponding function in CPP:
QScreen *getMonitor(QScreen* screen) { QList<QScreen*> screens = screen->virtualSiblings(); for(auto screen : screens) { qDebug() << "hi"; qDebug() << screen->name(); } return screens[1]; }
(The foreach loop is just for debugging purposes).
This doesn't work though. The program keeps saying:Error: Unknown method return type: QScreen*
Have I misunderstood something. What else can I try?
-
#include <QScreen>
P.S.
Range base for loops with non-const Qt containes are not totally efficient, there is the chance you make them detach. -
I have done that in the CPP file, but the problems seems to originate from the QML file.
-
I figured it out!
I used a function that set the screen for the window with a void function!