Results 1 to 15 of 15

Thread: webview cut off vertically in mobile devices

  1. #1
    Join Date
    Jul 2016
    Posts
    26
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Question webview cut off vertically in mobile devices

    as you can see in the gif below , the webview is cut in half . If i rotate the mobile it shows complete webview but hides the sidebar

    GIF : https://giphy.com/gifs/l0MYyfUxIgogGpasU

    qml code : https://ghostbin.com/paste/v45sp

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: webview cut off vertically in mobile devices

    Hard to tell with all the indentation being off, but the neither the parent item of the webview nor the Flickable around it seem to have a size.

    Cheers,
    _

  3. #3
    Join Date
    Jul 2016
    Posts
    26
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: webview cut off vertically in mobile devices

    i did ctrl + i to indent it in qt creator . it should look fine now

    https://ghostbin.com/paste/v45sp

    what should i do ? is there need to provide the size to webview and Flickable ?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: webview cut off vertically in mobile devices

    The WebView is anchored to fill an Item without size, so the WebView should also not have any size.
    It is a miracle you are seeing anything at all.

    Don't you want that item to be as large as the webview?
    I.e. the other way around?

    Also, the Flickable's size is the size of how much you see of its content.

    Why do you have it at all? Your code seems to push the Flickable's content item onto the stackview, basically making the Flickable have no content?
    Did you want to push the Flickable?

    Cheers,
    _

  5. #5
    Join Date
    Jul 2016
    Posts
    26
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: webview cut off vertically in mobile devices

    Quote Originally Posted by anda_skoa View Post
    Why do you have it at all? Your code seems to push the Flickable's content item onto the stackview, basically making the Flickable have no content?
    Did you want to push the Flickable?

    Cheers,
    _
    i just want to show proper webview , like any other normal apps .


    i have removed the flickable {} from the code . it was completely unecessary .

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: webview cut off vertically in mobile devices

    If you wrap the Item which you want to push onto the stack in a Component {}, then it won't be part of the Window's original content.
    I.e. you would be pushing a new object instead of taking the one already instantiated as a child of the window.

    Like the example in the StackView documentation, but using the Item around the WebView instead of the MouseArea in the example.

    Cheers,
    _

  7. #7
    Join Date
    Jul 2016
    Posts
    26
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: webview cut off vertically in mobile devices

    hello .

    I tried a lot but was not able to do it

    i tried something like this ( whole code same as in ghostbin )

    Qt Code:
    1. Component{
    2. id:searchview
    3. Item{
    4. id:load
    5. AnimatedImage {
    6. id: loading
    7. z:1000
    8. anchors.centerIn: webview
    9. source: "qrc:/images/loading.gif"
    10. visible: false
    11. }
    12. WebView{
    13. id: webview
    14. visible: false
    15. anchors.fill: searchview
    16. onUrlChanged: {
    17. // console.log(searchwebview.url);
    18.  
    19. extract_json();
    20.  
    21. }
    22. onLoadingChanged: {
    23. if(webview.loadProgress==="100" && url.toString().match("about:blank")){
    24. loadHtml("<html><head><title></title></head><body><center>Page not Found</center></body></html>");
    25. }
    26. }
    27. }
    28.  
    29. }
    30. }
    To copy to clipboard, switch view to plain text mode 

    error :
    qrc:/main.qml:20 Invalid alias reference. Unable to find id "webview"

    If possible can you do it for me ?

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: webview cut off vertically in mobile devices

    One thing that is wrong in the most recent code snippet is
    Qt Code:
    1. anchors.fill: searchview
    To copy to clipboard, switch view to plain text mode 
    because anchors only work with siblings or the parent.
    You probably wanted to write
    Qt Code:
    1. anchors.fill: parent
    To copy to clipboard, switch view to plain text mode 
    Also if you put AnimatedImage after the WebView, then you don't have to set "z" at all.

    As for the new error: do you need that alias property?

    Cheers,
    _

  9. #9
    Join Date
    Jul 2016
    Posts
    26
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: webview cut off vertically in mobile devices

    i need that alias property because : it helps me in giving value to p_url in extract_json function

    below code is original code without any changes .
    code : https://ghostbin.com/paste/yw26a

    can you use the above code to solve the issue .

    P.S. above code does not even contain the component{} that you suggested . WHY ? : because i think i am messing it more

  10. #10
    Join Date
    Jul 2016
    Posts
    26
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: webview cut off vertically in mobile devices

    @andka_skoa please help !!

  11. #11
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: webview cut off vertically in mobile devices

    Quote Originally Posted by arcade View Post
    i need that alias property because : it helps me in giving value to p_url in extract_json function
    You could move it into the WebView element since it only seems to be needed there.

    In any case, have you tried breaking down the code to the minimum that shows the problem?

    E.g. does it with with just a WebView in the window.
    With the WebView in an Item in the Window.
    With the Item in a StackView as the initialItem.
    and so on

    Cheers,
    _

  12. #12
    Join Date
    Jul 2016
    Posts
    26
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: webview cut off vertically in mobile devices

    Quote Originally Posted by anda_skoa View Post
    have you tried breaking down the code to the minimum that shows the problem?

    Cheers,
    _
    Yes , i also have one page that is very simple and has same issue ( i.e. webview cut in half ) . This page is for reading the pages offline

    below is the code :
    Qt Code:
    1. import QtQuick 2.6
    2. import QtQuick.Layouts 1.1
    3. import QtQuick.Controls 1.3
    4. import QtQuick.Window 2.2
    5. import QtQuick.Dialogs 1.2
    6. import QtQuick.Layouts 1.1
    7. import QtQuick.Controls 2.0
    8. import en.wtl.org 1.0
    9. import en.wtl.model 1.0
    10. import QtWebView 1.1
    11.  
    12. Pane{
    13.  
    14. id: view
    15. property string local_url : ""
    16. property string pid : ""
    17.  
    18.  
    19. ListView {
    20. width: 200; height: 250
    21.  
    22. model: myModel
    23. delegate: Component{
    24. RowLayout{
    25. Button {
    26. id: name
    27. text: title
    28. visible: true
    29. Layout.fillWidth: true
    30. onClicked: {
    31.  
    32. local_url = path+"/WTL_appdata/"+id+"/"+id+".html"
    33. console.log(local_url);
    34. pid = id;
    35. //webview.url = local_url
    36. webview.visible = true
    37. }
    38.  
    39. }
    40. }
    41.  
    42. }
    43. }
    44.  
    45.  
    46.  
    47.  
    48. WebView{
    49. id: webview
    50. url: "file:///"+path+"/WTL_appdata/"+pid+"/"+pid+".html"
    51. visible: false
    52. anchors.fill: parent
    53.  
    54. }
    55.  
    56. }
    To copy to clipboard, switch view to plain text mode 

  13. #13
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: webview cut off vertically in mobile devices

    Since I have no idea what "Pane" is, have you tried it with Item as the top level, with height and width set to some values and running that in qmlscene?

    Cheers,
    _

  14. #14
    Join Date
    Jul 2016
    Posts
    26
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: webview cut off vertically in mobile devices

    Quote Originally Posted by anda_skoa View Post
    have you tried it with Item as the top level, with height and width set to some values and running that in qmlscene?

    Cheers,
    _
    yes i tried with Item as top level with specific width and height , but this time it was even more cut off .

  15. #15
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: webview cut off vertically in mobile devices

    Can you provide an example that can be run by others?
    E.g. a QML file that can be run with qmlscene?

    Cheers,
    _

Similar Threads

  1. Comparing Qt Mobile with native mobile development
    By ChiliPalmer in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 1st November 2016, 09:52
  2. Replies: 1
    Last Post: 2nd October 2015, 09:34
  3. Vertically flipped QImage.
    By xtrememoo in forum Qt Programming
    Replies: 4
    Last Post: 11th August 2014, 02:36
  4. mobile extensions problems in Qt mobile app
    By hasnain in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 31st December 2010, 11:29
  5. Desktop environment for mobile devices
    By zuck in forum Qt Programming
    Replies: 4
    Last Post: 17th December 2009, 17:47

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.