I'm trying to play a WAV file in Symbian using Qt Creator.
I got this:
QSound::play("c:/notify.wav");
It works on Windows, but when I try it on Symbian it doesn't make a sound, but no error though.
This is most likely because it doesn't find the file (no notify.wav file under C:)
How can I include a WAV file so it gets installed to the Symbian device and so I can use its path to play it?
Use the DEPLOYMENT qmake instruction in your .pro file
e.g:
symbian{
sounds.sources = path to your wav
sounds.path = ./thewav.wav
DEPLOYMENT += sounds
}
This will deploy the wav in your app's directory. QSound::play("notify.wav") should work then, if not try to get the path to your directory from QApplication.
OK, it worked.
This is what I did:
In the .pro file:
symbian: {
sounds.sources = c:/notify.wav
sounds.path = c:/
DEPLOYMENT += sounds
}
In the program:
QSound::play("c:/notify.wav");
This way it works in Windows and in Symbian.
Related
I have learned that I can not bundle audio/video files within resource file in order to play them in my qml.
So, I have tried to use DEPLOYMENTFOLDERS in .pro file it does not copy the files.
It seems that QtCreator does not generate necessary code contents using DEPLOYMENTFOLDERS in .pri file.
Is there an easy way to say copy these files into build output location?
Visual studio C# has this option just saying one true/false to do this.
It should not be this hard. :-)
"Is there an easy way to say copy these files into build output location?" - this is a different task. You may achieve that with QMAKE_POST_LINK and writing a Makefile rule to copy the required files to the the output directory.
To copy the required file into the iOS bundle use QMAKE_BUNDLE_DATA. See https://qt-project.org/doc/qt-5-snapshot/platform-notes-ios.html
To copy the required file into the Andoid APK you need to write INSTALLS rules like that:
android {
...
assets.path = /assets
assets.files += LIST_OF_FILES
INSTALLS += assets
}
I compiled a library using the MinGW toolchain provided with Qt 5.0.2 on Windows. As a result I received a library.so file. First I failed using the library in a Qt application, but now I found out that everything works fine when I make a copy of the liblibrary.so file and call it liblibrary.dll or liblibrary.lib (which is the only file ending supported by the add library wizard in QtCreator).
Now I wonder if this is normal or if I should change something in order not to have both files (which are exact copies). Leaving one away makes the application crash during start up. I added the library as follows to my Qt pro file:
LIBS += -L"../path/to/library" -llibrary
INCLUDEPATH += $$quote(../path/to/library)
EDIT: I compiled the library using the MinGW of Qt, not as Qt project but using mingw32-make and the provided Makefile. As a result I get the liblibrary.so.
EDIT: It seems to work also when renaming the copy to liblibrary.dll instead of .lib. But still, I need two files to make the application work -- the .so and the .dll.
Chris
That's weird, I think you should get a *.a and *.dll files when building a shared lib with MinGW on Windows, as said in the documentation:
In windows, MinGW will output .a and .dll, MSVC2010 will ouput .lib and .dll. In linux, MinGW will output .so, .so.1, .so.1.0 and .so.1.0.0 – .lib, .a and .so are import libraries.
You definitely shouldn't rename your file!
Be careful to:
not to include the "lib" prefix after "-l" in your project file.
put everything after after "-l" in lower case as you're on Windows
not adding any extension to your library name after "-l"
add and reference the .h file used in your library
A real example using QtWebsocket lib:
INCLUDEPATH += "$${PWD}/include/"
LIBS += -L"$${PWD}/libs/" -lqtwebsocket
...
HEADERS += ... \
$${PWD}/include/QWsSocket.h \
...
In my include/ folder, I have the following file:
QWsSocket.h (taken from original project - required)
In my libs/ folder, I have the following file:
libQtWebsocket.a
QtWebsocket.dll
Edit: I struggled with this too initially. Have you tried to build your lib as a static lib instead (CONFIG += staticlib in your library project)? This might help you getting you *.pro file right before switching to using the shared library.
Edit 2: Ok, the fact that you get a *.so file is still a bit odd. In this question
the user has the same issue as you and keep both files, which is just a workaround. According to a later answer it seems that you need to modify your makefile to generate a file with the proper extension. Maybe this will help: http://www.mingw.org/wiki/sampleDLL
I'm trying to run the texteditor.pro file in the QtSDK\Examples\4.7\tutorials\gettingStarted\gsQml directory with Qt Creator. When I try to build the project I get a window that says
Could Not find the executable, please specify one
with three fields to load files. Snapshot of the dialog box.
I'm running windows 7 64bit, with Qt Creator 2.4.1
I've solved the problem it was a missing dll file, but the executable didn't ask for it, so I put all the dlls from Qtcreator -> bin in the same folder with the *.exe file, then I deleted file after another until I figured out what files are required.
* It is a brute force way, but It did the job.
* Here is the file that were missing (libEGL.dll)
This project is not created in the normal 'Qt-executable' kind format. Rather its a 'plugin' kind project. So you cant run it directly like other projects.
[If you will open the project files you wont find a main() function!, which is supposed to be the entrance point usually for a C++ Application. All you have are a couple C++ classes. Take that as a hint]
About this example they have given the complete details here. And I quote:
We need to compile the file dialog C++ plugin before the text editor
can run. To compile, enter the gsQml directory, then run qmake and
compile using make or nmake, depending on your platform. To run,
launch qmlviewer and open the texteditor.qml file.
Else:
You create your own project.
Add these class files and the respective qml files to this project.
Add a main and create the respective objects required.
Make an application viewer and give "texteditor.qml" path as its source.
I had the could not find executable window pop up in my face in Ubuntu 12.10.
Here's how I got the "error":
Created a folder named Project;
Inside it, I ran "qmake -project" and then "qmake";
Created a main.cpp file inside the folder;
Opened the Project.pro file with Qt Creator and added the line "SOURCES += main.cpp" to it;
Pressed Ctrl + R to build and run the project.
Later on I deleted the folder and created it again, but this time creating a main.cpp file before trying to run any commands. I opened the .pro file with Qt Creator, created a main function in the main.cpp file, and pressed Ctrl + R, and it built and ran!
My problem is simple.
How do I add an icon that appears in Windows Explorer ?
Not the specific window I want the whole application like the command prompt has the C:\ on the icon.
Is there any way I can do that without creating files and linking it to the .pro file ?
Can I change that base icon in the Qt Creator ?
If so, how ? If not how do I do it otherwise ?
Thank you
PS I have tried the other questions out there and none of them work at all
Basicaly, on Windows, you have to create an .rc file for your icon and then add a line in you .pro file for it :
RC_FILE = myapp.rc
All the details are available in Qt Documentation: Setting the Application Icon
In Qt 4, you need to create a .rc file like this:
IDI_ICON1 ICON DISCARDABLE "myIcon.ico"
You should add this to your .pro file :
win32: RC_FILE += MyApp.rc
In Qt 5 there is an automated process for setting an icon to the application executable file .
You can just add the following to the .pro file:
win32: RC_ICONS = myIcon.ico
Also store the .ico file in your application's source code directory.
Note that this is only for Windows. There are other ways to set application icon in Linux and Mac.
Please help me with solution of how to set the app icon for exe file on windows mobile platform? It means that icon should displays in explorer, task manager and so on.
This might be of helpful to you.
QApplication::setWindowIcon
In Qt 4, you need to create a .rc file like this:
IDI_ICON1 ICON DISCARDABLE "myIcon.ico"
You should add this to your .pro file :
win32: RC_FILE += MyApp.rc
In Qt 5 there is an automated process for setting an icon to the application executable file .
You can just add the following to the .pro file:
win32: RC_ICONS = myIcon.ico
Also store the .ico file in your application's source code directory.
Note that this is only for Windows. There are other ways to set application icon in Linux and Mac.