I am running some QML Unit tests and they being tested using "qmltestrunner" However, I am stuck on something that I am not sure it is possible to mock it.
Here a snipped on my "TitleBusyIndicator.qml":
import QtQuick.Layouts
import QtQuick.Controls.Material
import GUI.PageNavigatorPT 1.0
Rectangle
{
width: parent.width
height: parent.height
... a bunch of stuff
here is part of my unit test that will test the QML above
import QtQuick
import QtQuick.Controls
import QtTest
Rectangle
{
TitleBusyIndicator
{
id : titleBusyIndicatorId
}
However the import below is not known to the QMLTestRunner because it does not have the full project. It just testing one single qml file.
import GUI.PageNavigatorPT 1.0
When I try to run the unittest I get this (expected):
Running test = %QMLTESTRUNNER%\qmltestrunner -input tst_TitleBusyIndicator.qml
********* Start testing of qmltestrunner *********
Config: Using QtTest library 6.3.1, Qt 6.3.1 (x86_64-little_endian-llp64 shared (dynamic) release build; by GCC 11.2.0), windows 10
QWARN : qmltestrunner::tst_TitleBusyIndicator::compile()
tst_TitleBusyIndicator.qml produced 2 error(s):
tst_TitleBusyIndicator.qml:18,5: Type TitleBusyIndicator unavailable
TitleBusyIndicator.qml:21,1: module "GUI.PageNavigatorPT" is not installed
Is there a way to make qmltestrunner ignore the module or mock it? I could not find much documention on how to mock modules inside qml files for qml runner.
thank you.
Since you're using Qt6.3.1 you should consult https://doc.qt.io/qt-6/qtqml-syntax-imports.html specifically the section on QML Import Path in particular the section regarding setting the QML_IMPORT_PATH environment variable.
In short, you should consider setting QML_IMPORT_PATH prior to running qmltestrunner. This allows you to nominate additional Qt QML plugins that may not be part of the standard Qt install.
You can use QML_IMPORT_PATH to point to production, QA, dev, or even stub versions of your Qt QML Plugin.
If those plugins have additional dependencies, you may need to also append those to the PATH environment variable so that the qmltestrunner can find those as well.
For completeness, for those who are on older Qt5.15.x or older, the environment variable is QML2_IMPORT_PATH. For more details, see https://doc.qt.io/qt-5/qtqml-syntax-imports.html
Related
I'm following along the guide to setup Meteor Tabular v2.1.2 (guide). I have added the package and installed the theming packages. I'm using Meteor v2.8.0 and the project is a Blaze-based project.
In client/main.js, I set up the library as instructed.
import { $ } from 'meteor/jquery';
import dataTablesBootstrap from 'datatables.net-bs';
import 'datatables.net-bs/css/dataTables.bootstrap.css';
import "../imports/ui/body";
dataTablesBootstrap(window, $);
Now when I go to the browser, there is this error:
Can anyone help me on this?
So after serious debugging , I discovered it is enough to just import the DataTable module as such after installing it with npm
import { $ } from 'meteor/jquery';
import 'datatables.net-bs';
import 'datatables.net-bs/css/dataTables.bootstrap.css';
import "../imports/ui/body";
// You don't need the code previously here .
You can now setup you DataTable as such
$(element).DataTable(//Your config object)
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.
IntelliJ IDEA started highlighting errors in some of my import statements that worked previously. This is not unexpected as net.corda.finance is still in the "incubating" stage.
I am working in Java.
Corda Release: 3.3
Noticed this change on github: https://github.com/corda/corda/pull/4700
So I made what I thought are the necessary changes...
//Old
//import static net.corda.finance.utils.StateSumming.sumCashBy;
//New
import static net.corda.finance.contracts.utils.StateSumming.sumCashBy;
...but I'm still getting an error. I am sure I must be overlooking something simple.
#Kid101 put me on the right track by trying StateSumming.sumCashBy(contractState)
Once I did that IntelliJ recognized I needed to add:
net.corda:corda-finance:3.3-corda
...to the classpath. If I allowed IntelliJ to add it from the context menu the error reappeared every time gradle refreshed. So I added:
cordaCompile "$corda_release_group:corda-finance:$corda_release_version"
...to the build.gradle file under the dependencies section. No more errors with my import statement:
import net.corda.finance.utils.StateSumming;
...and no issues calling the sumCashBy method.
The change you mention is in Corda master branch, In CashTests.kt you can see how sumCashBy is imported, import net.corda.finance.contracts.utils.sumCashBy.
In corda/release-V4-branchpoint import is still net.corda.finance.utils.sumCashBy i.e. the change has not made in yet to V4.
Try to build the project again.
If using Java, try: StateSumming.sumCashBy(contractState)
You should import a dependency package.
You add below to build.gradle and refresh your IntelliJ project.
dependencies {
....
cordaCompile "$corda_core_release_group:corda-finance-contracts:$corda_core_release_version"
...
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();
}
}
}
i am using QtAV but getting this error so please help me:
QQmlApplicationEngine failed to load component
qrc:/main.qml:4 plugin cannot be loaded for module "QtAV": Cannot load library /home/intel/Qt5.7.0/5.7/gcc_64/qml/QtAV/libQmlAV.so: (libswresample.so.2: cannot open shared object file: No such file or directory)
at qrc:/main.qml:4 import QtAV1.6
using linux
The application cannot find your requested plugin.
You need to check if your import path is set correctly. If this is the case: please check if the plugin is installed correctly. You can use
export QML_IMPORT_TRACE=1
to check which import pathes are set.
And make sure, that all dependncies are installed as well. For instance libswresample ( see https://ffmpeg.org/libswresample.html )