I'm using PySide2 and QML.
I have an Image element in my qml file, and whenever I try to load an https URL in that image element I get the following error: QSslSocket::connectToHostEncrypted: TLS initialization failed
I'm on windows, and after looking online for this error it was suggested to put OpenSSL dlls alongside the executable when using vanilla Qt. Problem is that I'm using Python and I don't know where PySide2 looks for those dlls.
Any help would be appreciated.
Here is my QML image item:
Image {
id: image
height: parent.height - 5
width: parent.width - 5
source: url
sourceSize.width: image.width
sourceSize.height: image.height
asynchronous: true
fillMode: Image.PreserveAspectFit
}
url is a role in a python side model that is shared with QML using the setContextProperty method. The model is populated with image URLs from Reddit.
Download the OpenSSL version that's compatible with the version that's used to build the version of Qt you have installed. Make sure you put it where the Qt runtime can see when running your application.
Note OpenSSL version 1.0 is not backward compatible with 1.1
If you installed Qt using the pre-configured installer, then check the version that is pre-built with the version e.g OpenSSL v1.1 come with Qt 5.12
Related
I am new to Qt Quick for Python and I have a problem importing QtCharts in the QML file.
This image explain my whole Problemmodule QtCharts not installed
I allready verified the installation from the Qt Maintenance Tool.
Do you have any Suggestion ?
Thanks !
I was creating a simple webbrowser using webengine. I went to youtube and tried to play a live stream but failed. Same thing happens with every video which requires HTML5 video support in browsers. I didn't saw any recent problems which are identical to this. Qt says that webengine has HTML5 support from they released Qt5. Some old answers to same questions suggest them to compile qtwebengine your own. I tried several attempts and failed(may be my computer can't do the job). Some other say to enable proprietary plugins from the code. But in my case it too didn't work.
Running the code also logs an error WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed.
So this is my simple qml code.
import QtQuick 2.12
import QtQuick.Window 2.12
import QtWebEngine 1.0
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
WebEngineView{
anchors.fill:parent
url:"https://www.youtube.com/watch?v=iL53Y28Rp84"
}
}
Qt version: 5.15.1(GNU Public License )
Installed using qt online installer.
Your problem is likely that - as the error in the console said - you haven't initialized the web engine. In your main(), you must call QtWebEngine::initialize() before you do any rendering. So your main function should look like this:
#include <QtWebEngine>
int main(int argc, char* argv[])
{
QGuiApplication a(argc, argv);
QtWebEngine::initialize();
(...)
}
As per the Qt documentation, the initialize() function makes sure that the OpenGL context can be shared between the GUI and the renderer process.
Link to the Qt documentation.
The error message you get is trivial and they already gave you the solution in the other answer, instead my answer is to solve the underlying problem. Can't play youtube videos because chromium (and Qt WebEngine) was not compiled by enabling proprietary codecs. The solution is to recompile Qt WebEngine with that flag enabled.
From the comments it can be seen that the OP is using Qt 5.15.1 so he must follow the following steps:
sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
sudo apt-get install -y libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libxtst-dev libxss-dev libdbus-1-dev libevent-dev libfontconfig1-dev libcap-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libegl1-mesa-dev gperf bison nodejs
git clone -b 5.15.1 git://code.qt.io/qt/qtwebengine.git
cd qtwebengine
git submodule update --init
/path/of/Qt/5.15.1/gcc_64/bin/qmake . -- -webengine-proprietary-codecs
make
make install
Note: According to the logs shown in the comments /path/of/Qt/5.15.1/gcc_64/bin/qmake in your case is /mnt/volume1/main_file_folder/Home/Qt/5.15.1/gcc_64/bin/qmake
I created an empty QT Quick Application. my compiler is MinGW 64.
My project has main.qml file:
import QtQuick 2.14
import QtQuick.Window 2.14
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
}
but when I want to see its UI in designer it gives me an error:
Line: 1: Qt Quick emulation layer crashed.
I change User fallback QML emulation layer to "C:\Qt\Qt5.14.0\Tools\QtCreator\bin" but it does not work.
I had the same misbehaviour with my fresh Qt Creator installation on Ubuntu 20.04 with Qt6.
I solved my specific misbehaviour with the installation and usage of Qt5.12. In the Qt Quick Settings I chose the new installed Qt5.12 installation.
I want to check which version of a QtQuick module has been loaded.
There is an environment variable QML_IMPORT_TRACE you can set to display debugging info about the imports. I set it to 1 in the QtCreator project and got details in the console, mostly the path of the libs.
QQmlImportDatabase::addImportPath:
"/QT_INSTALL/5.9.3/gcc_64/qml"
QQmlImportDatabase::addImportPath: "qrc:/qt-project.org/imports"
QQmlImportDatabase::addImportPath: "/home/PROJECT_FOLDER"
QQmlImports(qrc:/main.qml)::addLibraryImport: "QtQuick" 2.0 as ""
QQmlImports(qrc:/main.qml)::importExtension: loaded
"/QT_INSTALL/5.9.3/gcc_64/qml/QtQuick.2/qmldir"
QQmlImportDatabase::registerPluginTypes: "QtQuick" from
"/QT_INSTALL/5.9.3/gcc_64/qml/QtQuick.2"
...
Based on the path of the installation you probably can guess the version of QtQuick from the Qt version...
But is there any direct way to display the exact module version at runtime?
(and ideally without debugging the imports)
Why rc1 but not release version?Because the macdeploy of release version has more bugs than rc1
The qml is very simple
import QtQuick 2.1
Rectangle{
width: 400
height: 300
color: "black"
}
my .pro
QT += core gui qml quick
CONFIG += c++11
SOURCES += \
main.cpp
OTHER_FILES += \
main.qml
But I can't even deploy this simple app
My scrips
#******copy main.qml into the bundle**********
cp /Users/Qt/program/experiment_apps_and_libs/qmlTest2/main.qml /Users/Qt/program/experiment_apps_and_libs/qmlTest2/qmlTest2.app/Contents/MacOs
#*******create the folder and copy the plugins into the bundle**********
mkdir qmlTest2.app/Contents/PlugIns
mkdir qmlTest2.app/Contents/PlugIns/QtQuick
mkdir qmlTest2.app/Contents/PlugIns/QtQuick/LocalStorage
cp /Users/yyyy/Qt5.1.0RC1/5.1.0-rc1/clang_64/qml/QtQuick/LocalStorage/libqmllocalstorageplugin.dylib qmlTest2.app/Contents/PlugIns/QtQuick/LocalStorage
cp /Users/yyyy/Qt5.1.0RC1/5.1.0-rc1/clang_64/qml/QtQuick/LocalStorage/plugins.qmltypes qmlTest2.app/Contents/PlugIns/QtQuick/LocalStorage
cp /Users/yyyy/Qt5.1.0RC1/5.1.0-rc1/clang_64/qml/QtQuick/LocalStorage/qmldir qmlTest2.app/Contents/PlugIns/QtQuick/LocalStorage
mkdir qmlTest2.app/Contents/PlugIns/QtQuick.2
cp /Users/yyyy/Qt5.1.0RC1/5.1.0-rc1/clang_64/qml/QtQuick.2/libqtquick2plugin.dylib qmlTest2.app/Contents/PlugIns/QtQuick.2
cp /Users/yyyy/Qt5.1.0RC1/5.1.0-rc1/clang_64/qml/QtQuick.2/plugins.qmltypes qmlTest2.app/Contents/PlugIns/QtQuick.2
cp /Users/yyyy/Qt5.1.0RC1/5.1.0-rc1/clang_64/qml/QtQuick.2/qmldir qmlTest2.app/Contents/PlugIns/QtQuick.2
#**********call macdeployqt***************
macdeployqt /Users/Qt/program/experiment_apps_and_libs/qmlTest2/qmlTest2.app -verbose=3
I run otool -L on every plugins I added, all of them become relative path after macdeployqt
When I run the program by lldb, it always give me the error messages
**file:///Users/Qt/program/experiment_apps_and_libs/qmlTest2/main.qml:23:1: module “QtQuick” is not installed import QtQuick 2.1 **
I am stuck staring at a blank white screen with no information on what I am doing wrong.
No document, current document is almost useless because the bugs of macdeploy haven't fixed since Qt5.0.1, and I have no idea
when they would fix it(maybe never get fixed).
no information telling me which dylib I need.It is highly frustrating!
Anybody know how to deploy QtQuick2 apps on mac os x?
If this keep going, maybe I better keep on using QWidget, atleast I don't have to suffer the deployment trouble again.
I am pretty surprise they spend a lot of times to develop QtQuick2 but do not release a useful document to teach us
how could we deploy the apps on their targeted platforms.
Check out this answer.
Thanks for miks131, MaximAlien and lasconic.
Remember to enter a correct qmldir, else the macdeploy would
not copy the QtQuick2 and QtQuick folder into the bundle
work around