Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QML Webview does not show in Android, but works in IOS
Forum Updated to NodeBB v4.3 + New Features

QML Webview does not show in Android, but works in IOS

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 1 Posters 310 Views
  • 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.
  • C Offline
    C Offline
    CellCS
    wrote on last edited by
    #1

    QT 5.12 +. QML for mobile app.

    webview content is using HTML file with embedded CSS and JSON data using plain JavaScript.

    <!DOCTYPE html>
    <html>
    <head>
    	<meta charset="UTF-8">
    	<title>Product List</title>
    	<style>
    		table {
    			border-collapse: collapse;
    			width: 100%;
    		}
    
    		th, td {
    			text-align: left;
    			padding: 8px;
    			border: 1px solid #ddd;
    		}
    
    		th {
    			background-color: #f2f2f2;
    			color: #444;
    		}
    
    		tr:nth-child(even) {
    			background-color: #f2f2f2;
    		}
    	</style>
    </head>
    <body>
    	<h1>Product List</h1>
    	<table>
    		<thead>
    			<tr>
    				<th>Name</th>
    				<th>Price</th>
    			</tr>
    		</thead>
    		<tbody id="product-list">
    		</tbody>
    	</table>
    
    	<script>
    		// Define the data as a JSON object
    		const products = {
    			items: [
    				{name: 'Product A', price: 9.99},
    				{name: 'Product B', price: 19.99},
    				{name: 'Product C', price: 29.99},
    			]
    		};
    
    		// Get the target element for the product list
    		const productList = document.getElementById('product-list');
    
    		// Loop through each product and append it to the table
    		products.items.forEach(item => {
    			const row = document.createElement('tr');
    			row.innerHTML = `
    				<td>${item.name}</td>
    				<td>$${item.price}</td>
    			`;
    			productList.appendChild(row);
    		});
    	</script>
    </body>
    </html>
    
    

    iOS shows correctly as following screenshot, but android shows empty/blank.:
    25ef73a0-9eae-42ce-b5d7-d030527f9731-image.png

    C 1 Reply Last reply
    0
    • C CellCS

      QT 5.12 +. QML for mobile app.

      webview content is using HTML file with embedded CSS and JSON data using plain JavaScript.

      <!DOCTYPE html>
      <html>
      <head>
      	<meta charset="UTF-8">
      	<title>Product List</title>
      	<style>
      		table {
      			border-collapse: collapse;
      			width: 100%;
      		}
      
      		th, td {
      			text-align: left;
      			padding: 8px;
      			border: 1px solid #ddd;
      		}
      
      		th {
      			background-color: #f2f2f2;
      			color: #444;
      		}
      
      		tr:nth-child(even) {
      			background-color: #f2f2f2;
      		}
      	</style>
      </head>
      <body>
      	<h1>Product List</h1>
      	<table>
      		<thead>
      			<tr>
      				<th>Name</th>
      				<th>Price</th>
      			</tr>
      		</thead>
      		<tbody id="product-list">
      		</tbody>
      	</table>
      
      	<script>
      		// Define the data as a JSON object
      		const products = {
      			items: [
      				{name: 'Product A', price: 9.99},
      				{name: 'Product B', price: 19.99},
      				{name: 'Product C', price: 29.99},
      			]
      		};
      
      		// Get the target element for the product list
      		const productList = document.getElementById('product-list');
      
      		// Loop through each product and append it to the table
      		products.items.forEach(item => {
      			const row = document.createElement('tr');
      			row.innerHTML = `
      				<td>${item.name}</td>
      				<td>$${item.price}</td>
      			`;
      			productList.appendChild(row);
      		});
      	</script>
      </body>
      </html>
      
      

      iOS shows correctly as following screenshot, but android shows empty/blank.:
      25ef73a0-9eae-42ce-b5d7-d030527f9731-image.png

      C Offline
      C Offline
      CellCS
      wrote on last edited by
      #2

      If using simple html content for android, webview in android show up the content, here is simple content:

      <!DOCTYPE html>
      <html>
      <body>
      <h1>My First Heading</h1>
      <p>My first paragraph.</p>
      </body>
      </html>
      

      how to make android webview to show a little complicated content? or have to upgrade with QT6.5 with using web engine in QML?

      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