Hi,

I'm trying to display qml file with help of QQuickView running in separate thread. My platform is beaglebone (am33xx qt5.5 compiled by yocto project with opengl).

I debug problem a bit and only after disabling of line 523 (in qtbase/src/gui/kernel/sources/qwindow.cpp)

d->platformWindow->setVisible(visible);

it was possible to use showFullScreen() in QquickView. The other show() function still doesn't work (means that the execution of the program is frozen after this place in code). The showFullScreen() is working restricted, it can show simple qml file, but doesn't show animation. There are some warnings in log file like :

WARNING: QObject::moveToThread: Current thread (0x6ff08) is not the object's thread (0x112740). Cannot move to target thread (0x156560)
WARNING: Updates can only be scheduled from GUI thread or from QquickItem::updatePaintNode()

When don't use separate thread and put everything in main.cpp then everything works as expected (including animations). Any ideas what could be wrong in my implementation? Thanks.

main.cpp:
Qt Code:
  1. #include <iostream>
  2. #include <QGuiApplication>
  3. #include <QQuickView>
  4. #include "mythread.h"
  5. #include <qdebug.h>
  6.  
  7. using namespace std;
  8.  
  9. int main(int argc, char ** argv)
  10. {
  11. QGuiApplication app(argc, argv);
  12. qDebug() << "app.thread() " << QGuiApplication::instance()->thread();
  13.  
  14. MyThread thread;
  15. thread.start();
  16.  
  17. return app.exec();
  18. }
To copy to clipboard, switch view to plain text mode 

mythread.cpp:
Qt Code:
  1. #include "mythread.h"
  2. #include <QDebug>
  3. #include <QString>
  4. #include <QMutexLocker>
  5. #include <QTime>
  6.  
  7.  
  8. MyThread::MyThread() {
  9. m_view = new QQuickView();
  10. engine = new QQmlApplicationEngine();
  11. window = NULL;
  12. }
  13.  
  14. void MyThread::run() {
  15.  
  16. qDebug() << "thread() " << currentThread();
  17.  
  18. m_view->setSource(QUrl(QStringLiteral("qrc:/test/loadingView.qml")));
  19. m_view->show();
  20.  
  21. exec();
  22. }
  23.  
  24. void MyThread::setWindow(QQuickWindow* ptr) {
  25. if (ptr)
  26. window = ptr;
  27. else {
  28. window = new QQuickWindow();
  29. }
  30. }
To copy to clipboard, switch view to plain text mode 

mythread.h
Qt Code:
  1. #ifndef MYTHREAD_H
  2. #define MYTHREAD_H
  3.  
  4. #include <QThread>
  5. #include <QMutex>
  6. #include <QQuickView>
  7. #include <QQmlApplicationEngine>
  8.  
  9. class MyThread : public QThread {
  10.  
  11. Q_OBJECT
  12. public:
  13. MyThread();
  14.  
  15. public slots:
  16. void run();
  17. void setWindow(QQuickWindow* ptr);
  18.  
  19. private:
  20.  
  21. QQmlApplicationEngine *engine;
  22. QQuickWindow *window;
  23. QQuickView *m_view;
  24. QObject *topLevel;
  25.  
  26. };
  27.  
  28. #endif // MYTHREAD_H
To copy to clipboard, switch view to plain text mode 

qml file:
Qt Code:
  1. import QtQuick 2.0
  2. import QtQuick.Window 2.2
  3.  
  4. Window {
  5. property var value: 0
  6. property string colGreyVeryLight: "#cccccc"
  7. property string colGreyLight: "#999999"
  8. property string colGrey: "#444444"
  9. property string colGreyDark: "#262a2b"
  10. property var timerIntervalTime: 250
  11.  
  12. id: screen
  13. width: 800
  14. height: 480
  15. color: "black"
  16. objectName: "list"
  17.  
  18. MouseArea {
  19. id: mouseArea
  20. width: 480
  21. height: 360
  22. anchors.rightMargin: 0
  23. anchors.bottomMargin: -497
  24. anchors.leftMargin: 8
  25. anchors.topMargin: 497
  26. anchors.fill: parent
  27. }
  28.  
  29. Text {
  30. id: loadingText
  31. x: 300
  32. y: 67
  33. width: 180
  34. height: 30
  35. color: "#ffffff"
  36. text: qsTr("Loading...")
  37. font.bold: true
  38. verticalAlignment: Text.AlignVCenter
  39. horizontalAlignment: Text.AlignHCenter
  40. font.pointSize: 14
  41. font.pixelSize: 14
  42. }
  43.  
  44. Timer {
  45. interval: timerIntervalTime; running: true; repeat: true
  46. onTriggered: (value == 4) ? value = 0 : value++
  47. }
  48.  
  49. Rectangle {
  50. id: rect1
  51. x: 65
  52. y: 192
  53. width: 50
  54. height: 50
  55. color: (value == 0) ? colGreyVeryLight : ((value == 1) ? colGreyLight : (value == 2) ? colGrey : colGreyDark)
  56. }
  57.  
  58. Rectangle {
  59. id: rect2
  60. x: 203
  61. y: 192
  62. width: 50
  63. height: 50
  64. color: (value == 1) ? colGreyVeryLight : ((value == 2) ? colGreyLight : (value == 3) ? colGrey : colGreyDark)
  65. }
  66.  
  67. Rectangle {
  68. id: rect3
  69. x: 354
  70. y: 192
  71. width: 50
  72. height: 50
  73. color: (value == 2) ? colGreyVeryLight : ((value == 3) ? colGreyLight : (value == 4) ? colGrey : colGreyDark)
  74. }
  75.  
  76. Rectangle {
  77. id: rect4
  78. x: 511
  79. y: 192
  80. width: 50
  81. height: 50
  82. color: (value == 3 ) ? colGreyVeryLight : ((value == 4) ? colGreyLight : colGreyDark)
  83. }
  84.  
  85. Rectangle {
  86. id: rect5
  87. x: 674
  88. y: 192
  89. width: 50
  90. height: 50
  91. color: (value == 4 ) ? colGreyVeryLight : colGreyDark
  92. }
  93.  
  94. }
To copy to clipboard, switch view to plain text mode