Sunday, April 28, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 6787  / 3 Years ago, mon, july 19, 2021, 4:11:40

Before I start, here is my setup:
Ubuntu 12.04.1
Default install of Qtcreator from Software Center.



For the rest, I' m doing all the thing from qtcreator



I wanted to try some examples from QT Assistant : Home > QtWebKit QML Module ;



the code is as simple as follow :



import QtWebKit 1.0

WebView {
url: "http://www.nokia.com"
preferredWidth: 490
preferredHeight: 400
scale: 0.5
smooth: false
}


and the error I'm getting is the one below



Qml debugging is enabled. Only use this in a safe environment!
file:///home/cyrildz/Public/Programming/UbuntuQml/UbuntuQml.qml:1:1: module "QtWebKit" is not installed
import QtWebKit 1.0
^


I got this error from qtcreator and this prevent me from running the example.



To set Qt5 on my desktop , I took the description from http://developer.ubuntu.com/get-started/gomobile/



that is :



sudo add-apt-repository ppa:canonical-qt5-edgers/qt5-beta1 && sudo apt-get update && sudo apt-get install qt5-meta-full && echo 'export PATH=/opt/qt5/bin:$PATH' >> ~/.bashrc


and then :



sudo add-apt-repository ppa:ubuntu-sdk-team/ppa && sudo apt-get update && sudo apt-get install qt-components-ubuntu qt-components-ubuntu-demos qt-components-ubuntu-examples qt-components-ubuntu-doc notepad-qml


For more info, I looked on the folder : /usr/lib/qt4/imports and i don't see anything relevant for the module QtWebkit1.0.
Could someone please help with this issue ?


More From » application-development

 Answers
3

You need to make sure that you are naming QtWebKit by the right version



import QtQuick 1.0 
import QtWebKit 1.0


That is great for Qt-Quick 1.0
But there have been some changes in version numbers in QtWebKit



import QtQuick 2.0 
import QtWebKit 3.0


You also need to make sure that you are using the correct import path with QtCreator



example if you are using qt5 BETA 1 form the canoinical qt edgers ppa(ppa:canonical-qt5-edgers/qt5-beta1) then under



/opt/qt5/imports/ 


has some imports in it. and is the default area for running qmlscene



But if you are using say Qt5 stable from there site ( http://qt-project.org/downloads ) then all imports should be under



/opt/qt5/5.0.0/gcc/qml


or you could place them under



/opt/qt5/5.0.0/gcc/imports


But then you need to set the path that qmlsceen is using like



 -I /opt/qt5/5.0.0/gcc/imports


you can also do this from Qt creator



enter image description here



Or from the command line



/opt/qt5/5.0.0/gcc/bin/qmlscene -I /opt/qt5/5.0.0/gcc/imports MyQmlfile.qml


I wrote more about this at this wiki



https://wiki.ubuntu.com/Qml-Phone-Alternitive



example of qtwebkit



import QtQuick 2.0
import QtWebKit 3.0

Rectangle{
id: rootangel
color:"black"
width: 1280 //parent.width
height: 720 //parent.height
//anchors.fill: parent

WebView {
url: "http://www.hulu.com"
width: rootangel.width
height: rootangel.height
scale: 1
smooth: false
}
}

[#33161] Tuesday, July 20, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
otputler

Total Points: 53
Total Questions: 105
Total Answers: 93

Location: Zimbabwe
Member since Wed, Nov 9, 2022
2 Years ago
otputler questions
Tue, Aug 23, 22, 14:36, 2 Years ago
Fri, Jul 23, 21, 11:57, 3 Years ago
Sun, Feb 12, 23, 18:37, 1 Year ago
;