I have a device with linux and I build the system with yocto. I use Qt as a webbrowser and it works for http sites. But when I want to show a https site I got a blank white site. It shows no error messages and also openssl is built and linked (otherwise i would get error messages?!). The folling code shows how i call the WebEngineView in a shell file.
import QtQuick 2.0
import QtQuick.Window 2.2
import QtWebEngine 1.2
Window {
width: 720
height: 1280
visible: true
WebEngineView {
anchors.fill: parent
url: "https://wiki.selfhtml.org/"
}
}
Does somebody knows any tipp?
Related
I am trying to implement a simple map view in a PySide6 Qt project by linking a QML file.
import QtQuick 2.0
import QtQuick.Window 2.14
import QtLocation 5.6
import QtPositioning 5.6
Item {
width: Qt.platform.os == "android" ? Screen.width : 512
height: Qt.platform.os == "android" ? Screen.height : 512
visible: true
Plugin {
id: mapPlugin
name: "osm"
}
Map {
anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(59.91, 10.75) // Oslo
zoomLevel: 14
}
}
To which Qt Creator or the main program starting the widget answer that the QtLocation and QtPositioning modules are not installed.
I'm on Fedora 35 KDE and there is indeed nothing in the repositories providing qml-modules-location, and the only modules available seem to be part of the KDE desktop. I installed PySide6 through pip3.
I tried to install Qt from the .run file on their website. I picked the "Additional libraries" that sounded close to it (datavisualization, charts, etc.) and the Qt studio. It downloaded some 9 GB of bloat and I still don't have the modules after.
How can I fetch those modules and where should I put them on my OS ? Preferably in a way that doesn't involve downloading another 10 GB because I don't have an unlimited data plan. It feels like it should just be grabbing some header files from a git repo and yet it's a turducken of unwanted libs, and everything on Qt Linux points to Ubuntu installations with apt-get.
I created an example Qt Wayland compositor and the QML code goes like this:
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.0
import QtWayland.Compositor 1.0
WaylandCompositor{
id:comp
WaylandOutput{
compositor:comp
sizeFollowsWindow:true
window:Window{
visible:true
width:700
height:700
Repeater{
model:shellSurfaces
ShellSurfaceItem{
shellSurface:modelData
onSurfaceDestroyed:shellSurfaces.remove(index)
}
}
}
}
ListModel{id:shellSurfaces}
WlShell{
onWlShellSurfaceCreated:{
shellSurfaces.append({shellSurface:shellSurface});
}
}
}
I know I can open a wiggly window using --platform wayland after the command. How can I open other software windows in the Wayland compositor(for example Firefox)?
(I don't know the basics of display servers and Wayland compositors. I think the compositor that I've created is just like a window manager and the apps that I open in it should just open in the compositor as it opens in a window manager).
When your compositor loads, it creates a socket on your computer. On my machine, it is located in /run/user/1000. It should be named something like 0-wayland.
In order to launch an app you need to pass the wayland display to it via a environment variable.
Example:
Launch firefox : WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 XDG_SESSION_TYPE="wayland" firefox
Launch kcalc(KDE's calculator): WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 XDG_SESSION_TYPE="wayland" kcalc
I think you get the idea.
I can run a boilerplate QT Quick Application (empty project) fine - the window shows and does not crash. If I then update the QML with some simple controls and run the application it shows the window for 3 seconds then crashes. This problem occurs when I run the example QT Quick application projects aswell.
The application output window shows:
The program has unexpectedly finished.
The process was ended forcefully.
What is going wrong and how can I fix this?
Information:
I am on Windows 10 64bit, using QT Creator, the project using QMake and mininum QT version allowed is 5.9
I am compiling in Debug mode using Desktop QT 5.11.1 MSVC2017 64bit. Note I am not able to compile in any other settings (MSVC2015, MinGW) - I get errors. If I compile in Release mode I still experience the same crash.
Desktop QT 5.11.1 MSVC2017 64bit does have an exclamation mark next to it No debugger setup
The following QML works:
import QtQuick 2.11
import QtQuick.Window 2.11
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
}
This causes it to crash:
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
menuBar: MenuBar {
Menu {
title: 'File'
}
}
header: ToolBar {
RowLayout {
}
}
TextArea {
id: area
anchors.fill: parent
}
}
I was getting this crash too, with only a rectangle on the Window.
For me the crash was fixed by adding the following line before instantiating my QGuiApplication :
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
from the docs, on windows, this tells qt to use the angle. Angle is driver that translates opengl into directx
you can read more about the diferent driver option on
http://doc.qt.io/qt-5/windows-requirements.html
I wrote a minimal example that display an Image and a DropShadow:
import QtQuick 2.9
import QtQuick.Window 2.2
import QtGraphicalEffects 1.0
Window {
visible: true
color: "black"
Image {
id: imgBackground
source: "file:///path-to-background.png"
Image {
id: imgSpinner
source: "file:///path-to-spinner.png"
x: imgBackground.width / 2 - imgSpinUp.width / 2
y: 260
visible: false
antialiasing: true
}
DropShadow {
id: sdwSpinner
anchors.fill: imgSpinner
horizontalOffset: 8
verticalOffset: 8
radius: 4.0
samples: 17
color: "#AA000000"
source: imgSpinner
}
}
}
In the development machine all works fine: I see the image with its shadow as expected. Now I want to deploy it on a target computer.
To find the needed file I created a virtual machine with a fresh install of the operating system and tried to run my application. Works as expected, fine!
Eventually, I deployed the same file to my customer machine... here the DropShadow is not rendered! If I set the visible property of the image I can see it (i.e. the paths are ok). Hence are the QtGraphicalEffects that don't work.
All the three machines (development, virtual machine, customer's computer) run the same o.s.: Windows 7 Home Premium 64-bit.
The Qt version is 5.9 MinGW.
Here the files I deployed:
imageformats/
images/
platforms/
QtGraphicalEffect/
QtQml/
QtQuick/
QtQuick.2/
libgcc_s_dw2-1.dll
libstdc++-6.dll
libwinpthread-1.dll
opengl32sw.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Network.dll
Qt5Qml.dll
Qt5Quick.dll
myapplication.exe
The development / virtual machine video card is a GeForce GTX 670, the customer one is an Intel GMA 4500.
What could prevent the rendering of such an item?
It sounds like an openGL issue.
Note: Some effects may not be available with all graphics APIs.
OpenGL, which is used by default in most cases, has full support for
all of them. However, the software backend for instance does not
support effects at all. Therefore, when running with graphics APIs
other than OpenGL, refer to the documentation of the QML types in
question to check if the effect is available. For more information on
the Qt Quick scene graph backends, see Scene Graph Adaptations.
http://doc.qt.io/qt-5/qtgraphicaleffects-index.html
I am working on ubuntu 14.04 with Qt 5.8 and trying to play video in my application using Qt multimedia module. I put "QT += quick multimedia" in ".pro".
ContentVideo.qml
import QtQuick 2.1
import QtMultimedia 5.0
Rectangle {
width: 400
height: 400
color:"black"
MediaPlayer {
id: mediaPlayer
autoPlay: true
autoLoad: true
source:"/home/macos/Desktop/FroggerHighway.mp4"
}
VideoOutput {
id:videoOutput
source:mediaPlayer
anchors.fill: parent
}
}
main.qml
import QtQuick 2.1
import QtQuick.Window 2.1
Window {
id: root
color: "black"
width: 400
height: 400
visible: true
ContentVideo {
anchors.fill: parent
}
}
My video is not running and I am getting black screen without any error. QT QML EXAMPLES video is working on my PC. Any help will appreciated, Thank you.
MediaPlayer.source is a URI and I don't think the value you are specifying is a valid URI. Try adding "file://" in front of the path the the mp4 file.
I had just met the same issue as yours, it seems that QtMultimedia will looking for decoders from gstreamer in system at run time, so I install video codec package:
sudo apt-get install gstreamer1.0-libav gstreamer1.0-vaapi
Then qml video player works correctly now
If the QML video examples work without any issues it's probably a problem that comes from the lack of codecs to encode your video. Check if you have all the Multimedia Dependencies. My guess is that the provided video samples are encoded in a open format the support for which is provided by default by your distro.
Add QT+= multimedia to your .pro file.
I faced the same problem on Arch and Debian. After installing the following packages, everything works fine.
ARCH:
extra/gstreamer
aur/gstreamer0.10
extra/gst-plugins-base-libs
extra/gst-plugins-good
extra/gst-libav
extra/qt5-tools
Installed with yay:
yay -S gstreamer gstreamer0.10 gst-plugins-base-libs gst-plugins-good gst-libav qt5-tools
Debian:
libqt5multimedia5-plugins
gstreamer1.0-plugins-good
gstreamer1.0-libav
libqt5multimediagsttools5
Installed with apt:
apt install libqt5multimedia5-plugins
Since qt6 prefers cmake instead of qmake so in case you want to add multimedia files to your cmake list you could perfrom the steps given below (the solution below worked on a mac (apple silicon))
First download the multimedia package from the qt maintenance tool (QtMultimedia)
Add it to the cmake project list by including the following lines
find_package(Qt6 6.2 COMPONENTS Multimedia REQUIRED)
Also update the target_link_libraries
target_link_libraries(yourprojectname, PRIVATE Qt6::Multimedia)
Also set autorcc on
set(CMAKE_AUTORCC ON)
Save your cmake file
Regarding the qml file the following code worked for me without errors
import QtQuick
import QtQuick.Controls
import QtMultimedia
ApplicationWindow
{
width:640
height: 480
visible : true
title: "audio player"
MediaPlayer {
id: player
source : "give your path to source file "
audioOutput: AudioOutput{}
Component.onCompleted:{
player.play();
}
}
}