Qt5.4.1 + QtMultimedia + Raspbian - qt

I have a problem with showing video using QtMultimedia on Raspberry Pi (Raspbian):
When I'm using QMediaPlayer + QVideoWidget it gives me an error: "this plugin doesn't support setParent"
When I'm trying to show video with QtQuick it gives me errors:
pi#raspberrypi ~/Desktop/QtApp $ ./JM
Unable to query physical screen size, defaulting to 100 dpi.
To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and
QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
GStreamer; Unable to pause - ""
Error: "No URI set"
Here is QtQuick project: https://gist.github.com/anonymous/e41fa0721bc895d7fe00
Video is placed here: /home/pi/Desktop/QtApp/video/adv.mov
How can I solve this problems?

Your program does not find your video.
Replace:
source: "./video/adv.mov"
with:
source: "file:///home/pi/Desktop/QtApp/video/adv.mov"
in your video.qml
You added your video.qml into the Qt resources:
app.load(QUrl("qrc:/qml/video.qml"));
This is practically a different file system, so your root folder is probably not what you expected... and your relative path points nowhere.

Related

Qt QML Settings are not saved/applied

I have simply copied this example from the docs, adjusting the import version number to the newest ones (but I tried with both for same result).
import QtQuick.Window 2.12
import Qt.labs.settings 1.1
Window {
id: window
width: 800
height: 600
Settings {
property alias x: window.x
property alias y: window.y
property alias width: window.width
property alias height: window.height
}
}
As opposed to advertised, the window geometry was not saved after I closed and reopened the window. In fact, it now doesn't show the window at all? (I tried re-running qmake and cleaning all)
I also get this warning every time I run the project in Qt Creator, regardless of whether I use Settings or not:
17:01:02: Starting C:...debug\untitled.exe...
QML debugging is enabled. Only use this in a safe environment.
qrc:/main.qml:10:5: QML Settings: Failed to initialize QSettings instance. Status code is: 1
qrc:/main.qml:10:5: QML Settings: The following application identifiers have not been set: QVector("organizationName", "organizationDomain")
1) Is the warning related to the issue?
2) How do I remove the warning?
3) How do I get the settings to be applied as advertised?
...Turns out I had to keep reading the docs to the end.
1) Warning is related to the issue.
2) Per the docs, add this at the beginning of the main in main.cpp
app.setOrganizationName("Some Company");
app.setOrganizationDomain("somecompany.com");
app.setApplicationName("Amazing Application");
3) Now works as advertised.

Qt Overlay over GStreamer

I've a question considering the current setup:
Yocto Linux on iMX6
Neither a window-, nor a display-manager
A fully functional Qt Application, tested on Debian 9
The application consists of 2 main elements:
A GStreamer part, with a imxg2dvideosink
A semi-transparent Qt Overlay, which should be displayed over the stream
The question:
How can I accomplish to display the overlay over the stream, while having both parts on fullscreen (filling the whole screen)? Possible solutions:
/dev/fb1 as an overlay to /dev/fb0 (How to split a single application to two fb's ?)
Use a display-manager ?
Use a window-manager ?
linuxfb instead of eglfs ?
My current (not working) solution:
Using -platform eglfs
The application will first start GStreamer, and afterwards show the overlay
I've found the solution myself. Shared below:
1) Run Qt Application on /dev/fb1:
export QT_QPA_EGLFS_FB=/dev/fb1 (Specify /dev/fb1 as eglfs framebuffer)
echo 0 > /sys/class/graphics/fb1/blank (Unblank framebuffer)
fbset -fb /dev/fb1 --geometry <your geometry here> (Set framebuffer geometry)
./YourApplication -platform eglfs (Run application)
Use a Color Key if you want full opacity while having fully transparent parts of your overlay.
2) Run GStreamer on /dev/fb0:
gst-launch-1.0 videotestsrc ! imxg2dvideosink framebuffer=/dev/fb0
This is the solution for eglfs. Other possibilities are linuxfb.

JavaCV VideoWriter does not open

I want to record a video using JavaCV in JOGL (Java Binding for OpenGL).
This is the code to open the video file:
VideoWriter wv;
wv.open("video.avi", CV_FOURCC_DEFAULT, 30 , new Size(width, height), true);
The problem is that wv.isOpened() always returns false and no video file is created.
Things I've tried:
Change "video.avi" to "video.mp4"
Change CV_FOURCC_DEFAULT to -1
Change width, height, fps values
Anyone have achieved this?
My machine is running an Ubuntu 14.04 LTS with JavaCV v1.3.2 and JOGL v2.3.2.
When using OpenCV with C++ I had to define this constant:
const int VIDEO_CODEC_FOURCC = CV_FOURCC('M','J','P','G');
Try doing using the CV_FOURCC function and the use the .avi file extension as you had originally. Also try to make sure that the camera's frame dimensions are the same as the Size that you passed in your width and height.

What is qmltestrunner?

I have gone through the documentation provided by Qt on TestCase, Qt Quick Test Reference Documentation, Ubuntu QML unit testing, Testing with qmltestrunner part 1 & 2, Writing and running qml testcases, How to create a Qt-Quick Test
All that I have found about it is:
Qmltestrunner is a tool used for unit testing. This tool allows to execute QML files as test cases. These files should contain test_functions. Qmltestrunner is an open-source project and its source code can be found from the github.
But there are few questions for which I'm looking out for answers:
qmltestrunner documentation? where can I find it? (Could not find wiki page for it)
Is qmltestrunner part of qt quick test framework?
What all dependencies are there for qmltestrunner?
Is there any proper example where I can find complete explanation about QML unit testing? qt quick test framework explains running-tests which I couldn't understand.
Thank you
Unfortunately there's no documentation for qmltestrunner (I cannot one). If you only want to know how to use it, qmltestrunner.exe -h may help you. Most options are described in Qt Test Overview.
Yes. Qt Quick Test Reference Documentation - Running Tests says you need a .cpp file that contains QUICK_TEST_MAIN(xxx) and a .pro file that contains CONFIG += qmltestcase, and build this project to run your QML unit tests. The output binary file of this project is (almost the same as) qmltestrunner.
To run qmltestrunner (in Windows with Qt 5.7, for example), you need at least the following modules: Qt5Core.dll, Qt5Gui.dll, Qt5Network.dll, Qt5Qml.dll, Qt5Quick.dll, Qt5QuickTest.dll, Qt5Test.dll, Qt5Widget.dll. And some extra modules for your QML files if needed (ex. QtQuick Controls 2)
TestCase describes how to write a unit tests in QML. To run the file, simply run qmltestrunner.exe -input C:\My\Testing\File\Path\tst_myComponentTest.qml in command line.
Here's simple step-by-step example about how to write a QML component with unit tests. For example, assume that we have a ExpandButton that expands when it is clicked:
//ExpandButton.qml
import QtQuick 2.7
import QtQuick.Controls 1.2
Button {
width: 50; height: 50
onClicked: { width = 100; }
}
To test this behavior, write a tst_ExpandButton.qml:
import QtQuick 2.7
import QtTest 1.0
Item {
width: 800; height: 600
ExpandButton {
id: expandButton
anchors.centerIn: parent
}
TestCase {
name: "ExpandButton"; when: windowShown
function test_clickToExpand() {
var widthBeforeClick = expandButton.width;
mouseClick(expandButton);
var widthAfterClick = expandButton.width;
verify(widthBeforeClick < widthAfterClick);
}
}
}
Now we have two QML files, ExpandButton.qml and tst_ExpandButton.qml. Run the unit test with qmltestrunner.exe -input D:\aaa\bbb\tst_ExpandButton.qml and you can see the result:
********* Start testing of qmltestrunner *********
Config: Using QtTest library 5.7.0, Qt 5.7.0 (i386-little_endian-ilp32 shared (dynamic) release build; by MSVC 2015)
PASS : qmltestrunner::ExpandButton::initTestCase()
PASS : qmltestrunner::ExpandButton::test_clickToExpand()
PASS : qmltestrunner::ExpandButton::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 13ms
********* Finished testing of qmltestrunner *********
http://doc.qt.io/qt-5/qtquick-qtquicktest.html This will help in understanding qmltest runner
http://doc.qt.io/qt-5/qml-qttest-signalspy.html This will help in understanding signal spy which is used to catch signals
http://doc.qt.io/qt-5/qml-qttest-testcase.html This will help in writing each test case

How can i fine-tune qt5 for an embedded system?

I am using yocto, and already have a build of qt5 in my image and it works. The issue is that it is HUGE.
So, I tried to use a .bbappend recipe in my layer for qt where I experimented with using
PACKAGECONFIG_remove = " qtnetworking qtdeclarative sql-mysql qtscript...etc";
and
EXTRA_OECONF = " -no-accessibility -no-feature-MDIAREA -no-feature-DRAGANDDROP ...etc";
I even removed all the feature disablement config params in EXTRA_OECONF and just added -qconfig minimal or -qconfig medium.
====> the result is always the same: compilation failure in the qt corelib or qtwidgets.
I want to disable networking, printing, and mdi support. How can I do that?
Much appreciated!

Resources