Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDeclarativeView window cannot transparent on android



  • Hello everyone,
    I use QMainWindow create as first window,and then QDeclarativeView create as other window.
    I set the QDeclarativeView as transparent, the QDeclarativeView window can transparent on Linux and window system,
    But I find this is not OK on android, I found that the QDeclarativeView window cannot transparent

      code as below:
      QMainWindow window;
      window.resize(800, 480);
     ........>>painter the picture to MainWindow
      window.show()
      QDeclarativeView * m_pDeclarativeView = new QDeclarativeView ();
      // set view as transparent background
      m_pDeclarativeView->setAttribute(Qt::WA_TranslucentBackground,true);
      m_pDeclarativeView->setStyleSheet(QString("background: transparent"));
      m_pDeclarativeView->setWindowFlags(Qt::FramelessWindowHint);
      m_pDeclarativeView->setSource(QUrl::fromLocalFile(("main.qml")));
      m_pDeclarativeView->show();
    
      main.qml
      import QtQuick 1.1
      Rectangle {
        width: 360
        height: 360
       color: "transparent"
    
       MouseArea {
         anchors.fill: parent
         onClicked: {
            Qt.quit();
         }
     }
    
      Text {
          color: "red"
          text: qsTr("Hello World")
          anchors.centerIn: parent
      }
    

    }

    Could you help me solved this problem?
    Thanks in advance!


  • Moderators

    @Brian.H QDeclarativeView is deprecated in Qt5 and IMO with Qt4.8 it was never taken further for android platform. I would strongly suggest you update to Qt5 possibly Qt 5.4.1. It works nicely on android.


  • Moderators

    Hi @Brian.H,

    To extend @p3c0's answer, you should use QQuickView instead of QDeclarativeView. (In other words, Qt Quick 2 instead of Qt Quick 1)



  • Hi @p3c0,
    Hi @JKSH,
    Thank you very much for your suggestion!
    Because My android platform is 2.3.3, and when I use QQuickView instead of QDeclarativeView,
    I found that the qml page could not draw on the android system,so I use the QDeclarativeView
    to draw the qml.


  • Moderators

    @Brian.H said:

    Because My android platform is 2.3.3, and when I use QQuickView instead of QDeclarativeView,
    I found that the qml page could not draw on the android system,so I use the QDeclarativeView
    to draw the qml.

    Ah, I see.

    I don't have experience with an old platform and Qt Quick 1, sorry...!


Log in to reply