Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QML webview not fitting in widget layout on android.
Forum Updated to NodeBB v4.3 + New Features

QML webview not fitting in widget layout on android.

Scheduled Pinned Locked Moved General and Desktop
qml webviewqlayout
3 Posts 2 Posters 2.4k Views 2 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.
  • M Offline
    M Offline
    musimbate
    wrote on 27 Jul 2015, 02:24 last edited by
    #1

    Hello,
    I have a widget layout like that loads a webview within a QQuickWidget like this:

    QQuickWidget *mQuickWidget = new QQuickWidget(this);
        QUrl mSource("qrc:/webviewcontainer.qml");
        mQuickWidget->setSource(mSource);
    
        QVBoxLayout * layout=new QVBoxLayout();
    
        QPushButton * button1=new QPushButton("button1",this);
        QPushButton * button2=new QPushButton("button2",this);
    
        layout->addWidget(button1);
        layout->addWidget(mQuickWidget);
        layout->addWidget(button2);
    
        setLayout(layout);
    

    I want the webview to show up in the middle of the two buttons.But for some reason it is just ignoring the layout and showing full screen .My qml looks like this :

    import QtQuick 2.0
    import QtQuick 2.2
    import QtQuick.Controls 1.1
    import QtWebView 1.0
    import QtQuick.Layouts 1.1
    
    
    Rectangle {
        width: 1000
        height: 1800
        color: "red"
    
        ScrollView {
            id: scrollview
             anchors.fill: parent
             
            WebView {
                id: webView
                url : "http://www.blikoon.com"
            }
        }
    }
    

    I want the webview to fill the red rectangle.

    I am running this on android .Is there something I am missing or even a way around this?
    Thank for your time.

    Why join the navy if you can be a pirate?-Steve Jobs

    P 1 Reply Last reply 27 Jul 2015, 11:39
    0
    • M musimbate
      27 Jul 2015, 02:24

      Hello,
      I have a widget layout like that loads a webview within a QQuickWidget like this:

      QQuickWidget *mQuickWidget = new QQuickWidget(this);
          QUrl mSource("qrc:/webviewcontainer.qml");
          mQuickWidget->setSource(mSource);
      
          QVBoxLayout * layout=new QVBoxLayout();
      
          QPushButton * button1=new QPushButton("button1",this);
          QPushButton * button2=new QPushButton("button2",this);
      
          layout->addWidget(button1);
          layout->addWidget(mQuickWidget);
          layout->addWidget(button2);
      
          setLayout(layout);
      

      I want the webview to show up in the middle of the two buttons.But for some reason it is just ignoring the layout and showing full screen .My qml looks like this :

      import QtQuick 2.0
      import QtQuick 2.2
      import QtQuick.Controls 1.1
      import QtWebView 1.0
      import QtQuick.Layouts 1.1
      
      
      Rectangle {
          width: 1000
          height: 1800
          color: "red"
      
          ScrollView {
              id: scrollview
               anchors.fill: parent
               
              WebView {
                  id: webView
                  url : "http://www.blikoon.com"
              }
          }
      }
      

      I want the webview to fill the red rectangle.

      I am running this on android .Is there something I am missing or even a way around this?
      Thank for your time.

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 27 Jul 2015, 11:39 last edited by
      #2

      @musimbate Does setting resizeMode to QQuickWidget::SizeRootObjectToView work ?

      157

      1 Reply Last reply
      0
      • M Offline
        M Offline
        musimbate
        wrote on 9 Aug 2015, 02:56 last edited by
        #3

        No it didn't work ,the webview was still floating on top of other layed out widgets.Other QML elements fit in ok ,it is just the webview that could not. A temporary solution we used is this :
        https://github.com/gakwaya/qt-android-native-web-view-example ,I hear that when your UI is completely done in QML ,you don t have this problem ( the mini browser example is a demonstration of that.We were planning on redesigning our UI in QML anyway so this is a plus.

        Why join the navy if you can be a pirate?-Steve Jobs

        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