I am developing a Qt application which will have a video playing in the center of the screen. This video is included locally for the application. I am new to Qt development, and thus far I have only seen examples of including resources in the .qrc file.
When I add the video (which is about 2 minutes long), compilation takes approximately 8-10 minutes. Normally it takes between 1-3 seconds to compile.
Is there a way to include a large file (such as a video) to be packaged and distributed with the application?
Adding a large resource like a video to the qrc file carries some overhead, so it's best to avoid using it there. What I would personally do differs from each platform, so I've broken it down:
Windows: ship a .exe installer package with the video file in a folder, so when it's installed the video file is in a specific path relative to the application binary, then load the video file from there.
OS X: ship a .dmg containing the .app bundle, use the QMAKE_BUNDLE_DATA build command to copy the video file into .app bundle, so it's in a specific path relative to the application binary.
Linux: this entirely depends on how you want to distribute, if you're distributing as an installable package (for apt, or yum) then add the video file into the install package, if it's as a .tar.gz then add the video to that.
Related
I am working for an embedded project, UI developed in QML and backend logic developed using DB/other system calls in C++/Qt.
Which is the best approach to deploy qml files?
Does It adding to .qrc (as resource) and compile to executable application?
or
Load QML files from import folder (QML files will be deployed)?
or any other suggesion?
I have around 200 QML files.
QML files in the file system
Files are stored without compression and encryption
Faster to build but slower to deploy
Stored without compression so they take more storage space
Easy to do UI changes on the fly on target (just edit QML and restart)
QML files in the resource file
Resources are compiled to the binary file making the executable file size bigger
Slower to build but faster to deploy.
Takes less storage space because resources are compressed by default.
Because the executable size is bigger the program takes more memory when running.
You can't do changes to UI without re-compiling
See from the link the following chapter Managing Resource Files with the Qt Resource System for an example of relative path referencing.
I don't have any strong opinion but here some of my thoughts:
If memory usage is an issue then you might go without embedded resources and make sure you use dynamic loading of components as much as possible. In the development phase it's easier to go without embedded resources. If it's a customer project I would do the customer delivery as qml files embedded. This prevents the customer from tweaking the UI code themselves.
I have deployed a QML application (static build on windows, following this how-to: http://qt-project.org/wiki/How-to-build-a-static-Qt-for-Windows-MinGW). However, the qml_import_trace (screenshot below) reveals that LocalStorage is loaded from the Qt/Static folder on the development computer, not from the release folder. Hence, when launched at another computer, the LocalStorage module is not found. How may the LocalStorage plugin/module be shipped with the application?
Including the following lines in the .pro files will give svg support. Am I only missing a qtplugin for sql/localstorage? In that case, what is the proper plugin name? Also, where can I find valid inputs for QTPLUGIN+= and QT+= ?
QTPLUGIN += qsvg
QT += svg sql
If I understand you correctly you want to copy the needed files to the release folder automatically.
Use the windeployqt.exe (in qt/bin folder) with --qmldir option. It will scan the given path for QML files and collect the QML components imported in those files.
A solution, although not optimal, was to manually copy the QtQuick/LocalStorage folder from the static folder into the release folder
I am coding a GUI using Qt. When I run the application using QtCreator, my images do not load, and I receive the following error:
QPixmap::scaled: Pixmap is a null pixmap
Yet, when I run the application via command line, everything displays perfectly.
Why so? And how can I get QtCreator to load my images properly?
NB: Those images are barely 20ko each, so what I read about images being too big can't apply.
EDIT: A typical filename is 'Images/Cards/Base/card01.jpg', where Images is a subdirectory of my project directory (the code being at the root)
If you are working with images that should be bundled with the application, such as icons, then you should try and make use of the Qt Resource system.
This allows you to build the resources into the actual project and reference them in a filesystem independent syntax. i.e.: :/icons/myIcon.png
Most likely you have a difference between the relative location of the file in Qt Creator vs the command line.
So, I made a Qt application on Qt Creator that displays jpg files and mp3 files(using phonon).
On deploying the application with dynamic linked libraries I had to copy to the same folder QtCore4.dll, QtGui4.dll, phonon4.dll, mingwm10.dll and libgcc_s_dw2-1.dll as required by Windows.
The problem is that the jpg files and mp3 files are only shown on pcs with the QtSDK installed. In other pcs the exe file runs, opens the user interface and does everything right except showing jpg and mp3 files. The directory path is not the problem because it opens a pdfviewer that I put in the same folder. Do I need to provide other files?
Qt relies on plugins for most of the file formats. For Jpeg you will need to include the qjpeg4.dll found in the plugins/imageformats directory. For Phonon, you will also need to include the appropriate backend DLL found in the plugins/phonon_backend directory.
All the information you need is contained within the Qt documentation on Deploying an Application on Windows and especially the section on Qt Plugins.
Basically I am trying to load the image as a texture using QPixmap:
texture[T_WALL] = bindTexture(QPixmap(":/images/wall.png"), GL_TEXTURE_2D);
The code works on my development machine, but not in the vm / other pcs without QT. Initially I was using jpegs and just assumed that I messed up the plugins, but as I understand, no plugins are needed for png files so I have no idea where the problem is.
Results are the same when loading local files and using Qt resources.
I am deploying libgcc_s_dw2-1.ddl, mingwm10.dll, QtCore4.dll, QtGui4.dll, QtOpenGL4.dll. Do I need anything else?
Try adding an imageformats directory to your application directory and put qmng4.dll there. See my answer to the question Qt dll deployment on windows
If it still does not work, get the Sysinternals suite which contains dgbview.exe that allows you to watch qDebug messages (even for release builds).