Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QDeclarativeView window cannot transparent on android
Forum Updated to NodeBB v4.3 + New Features

QDeclarativeView window cannot transparent on android

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 1.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brian.H
    wrote on last edited by Brian.H
    #1

    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!

    p3c0P JKSHJ 2 Replies Last reply
    0
    • B Brian.H

      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!

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @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.

      157

      B 1 Reply Last reply
      0
      • B Brian.H

        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!

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        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)

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • p3c0P p3c0

          @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.

          B Offline
          B Offline
          Brian.H
          wrote on last edited by Brian.H
          #4

          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.

          JKSHJ 1 Reply Last reply
          0
          • B Brian.H

            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.

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            @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...!

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved