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
Related
I wanted to learn OpenGl with Cpp using QT-Creator but it seems that i didn't linked my GLFW lib right.
I used
sudo apt-get install libglfw3 libglfw3-dev libglfw3-doc
and
sudo apt-get install libglew-dbg libglew-dev libglew1.13
to install them and afterwards, the QT_Creator "showed" me
//GLEW
#include "GL/glew.h"
//GLFW
#include "GLFW/glfw3.h"
so I thought, I could use them, but i got an "undifened reference to ...".
I already looked at this question, but it doesn't seem to work. And I never worked with CMake or qmake before, so i can't see my mistake.
I can provide my enviroment setup notes for you, or you can read it from my sites, But prevent my site url from invalid someday, I rewrite it here.
Install glfw
First. we need to install dependencies on ubuntu
sudo apt-get install xorg-dev
sudo apt-get install libglu1-mesa-dev
Install glew
Then download source package at official
Extract your package and open your terminal, then cd to what your package location which you just extracted.
Do following commnad to install
make extension
make
sudo make install
sudo make clean
Open QT project and set opengl settings
Open a console project in QT
Add following settings in your .pro file anywhere.
LIBS +=-lGLEW -lglfw3 -lGL -lX11 -lXi -lXrandr -lXxf86vm -lXinerama -lXcursor -lrt -lm -pthread
Try a simple test.
#define GLEW_STATIC
#include <GL/glew.h>
#include<GLFW/glfw3.h>
int main(int argc, char *argv[])
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
return 0;
}
Enjoy it
If you have purpose only learn openGL without help library like glfw or glew you can use QOpenglWidget or QOpenglWindow with QOpenglGLFunctions. Qt give wrapper for all openGL functions, however you can use functions from raw opengl. You can not even use QOpenglWindow or QOpengGlWidget. Qt provides a lot of examples, for instance
http://doc.qt.io/qt-5/qtopengl-cube-example.html
http://doc.qt.io/qt-5/qtgui-openglwindow-example.html
I stumbled on the same problem. I followed Tokenyet answer but I also added also -ldl to the end of LIBS in .pro file and it worked.
I have had the same problem, while trying to develop a a console application project using Qt. I fixed the problem using
-lglfw (not -lglfw3)
it seems like lglfw3 (.so or .a file or whatever) does not exist in the Lib folder unless you compile it your self (video)
*More over libglm-dev is needed for projects that include glm header files. So lanch ubuntu software center to install it or lanch
sudo apt-get install libglm-dev
I am trying to build Qt using meta-toolchain-qt5, but when I do this via poky-glibc-x86_64-meta-toolchain-qt5-cortexa7hf-vfp-vfpv4-neon-toolchain-2.0.1.sh, I don't see anything about QtWebEngine in the sysroot directory.
I also tried to build Qt using the following command
bitbake meta-toolchain-qt5
but it is the same result; I don't have anything regarding Qt WebEngine.
How can I build Qt with QtWebEngine support?
Looking at meta-toolchain-qt5 it inherits populate_sdk_qt5, which in turns adds packagegroup-qt5-toolchain-target to the SDK. Taking a closer look at packagegroup-qt5-toolchain-target, reveals that the packagegroup doesn't directly include qtwebengine. Thus, if nothing else in packagegroup-qt5-toolchain-target drags in qtwebengine as a dependeny, qtwebengine won't be installed.
If you add qtwebengine to RDEPENDS_${PN} in packagegroup-qt5-toolchain-target, you'll get the relevant qtwebengine packages in your SDK.
I just need to play simple audio wav or mp3 file from QT 5.1 application running on Raspberry Pi.
My console application is successfully building and deploying to pi.
However I'm getting a message when I try to play the file:
defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
I try to play the file like this:
QMediaPlaylist * playlist = new QMediaPlaylist;
playlist->addMedia(QUrl::fromLocalFile(hall1_5min));
playlist->addMedia(QUrl::fromLocalFile(hall1_start));
playlist->setCurrentIndex(1);
QMediaPlayer * player = new QMediaPlayer;
player->setPlaylist(playlist);
player->play();
As I understand there is something wrong with my QTMultimedia compilation.. I need help with that.
I've compiled with these instructions.
I've installed some gstreamer packages as mentioned above,
However, when I compile QTMultimedia module
when running qmake - it doesn't detect gstreamer..
How can I compile QTMultimedia with explicitly specified gstreamer or other media service driver?
If QtMultimedia is not being built, how can you expect it to work running the application?
That probably means you're still missing some dependencies or something else is wrong with your env. Maybe you didn't set pkgconfig paths correctly. You can also try with this guide I wrote: http://thebugfreeblog.blogspot.it/2013/03/bring-up-qt-501-on-raspberry-pi-with.html. I had issues with audio and gstreamer, but some time has passed and something might have changed since then.
If after building and deploying the QtMultimedia module and the gstreamer plugin you still get that, use the QT_DEBUG_PLUGIN env variable to get some logs.
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
I am running Code::Blocks 10.05 with the MingW compiler package on a Win7-32 box.
I downloaded and installed the Qt libs for Windows/MingW (qt-win-opensource-4.7.3-mingw.exe) - installation went smoothly - BUT when it prompted me for the directory for MingW and I pointed it to Code::Blocks installation directory, Qt installer told me my Qt package was for MingW 4.4 and I had 4.4.1 installed - 'installation may not work'. I installed anyhow, figuring there's no significant difference between 4.4 and 4.4.1 and the installation finished without error, all the Qt libs and tools are installed.
Afterwards, in Code::Blocks I created a small test project using the Code::Blocks wizard - here is the code:
#include <QApplication>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
return app.exec();
}
The code built fine in the IDE - no errors or warnings, but when I ran it, I immediately received this error message, and the app exited with an error code:
"The procedure entry point _ZI3qFlagLocationPKc could not be located
in the dynamic link library QtCore.dll"
Anybody know what's going on here? Is it because of the MingW version discrepancy I was warned on, or some other reason? How can I fix this? I want to use Qt Code::blocks, not Nokia QtCreator.
TIA
Add %qtDir%\lib to your path before trying to copy all to system32. Reboot after adding, then all should run fine.
Also, you may need to rebuild qt libs with your compiler if all is still not working...
I used to have that errors, too. And having Qt libs in PATH doesn't seem to help, someone told me to put them into %WINDIR%\system32 and everything works fine after that...
You should create the variables:
QTDIR - C:\Qt\4.7.3 (it's mine, you should write yours)
QMAKESPEC - win32-g++ (for MinGW)
PATH - C:\Qt\4.7.3\bin;C:\mingw\bin