Base icon for a Qt application - qt

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.

Related

How do I add an entire directory to a QT creator project

I have an existing QT Creator project. I want to add an entire directory to this project. I see that I can right click in the project file browser tree and "Add Existing Files..." However through this dialog box, I can only add individual files. How can I include an entire directory?
The simplest way is to directly edit your .pro file, add HEADERS += mydir/*.h and SOURCES += mydir/*.cpp and the contents of the whole directory will show up in QT Creator. Further reference: http://qt-project.org/doc/qt-5/qmake-project-files.html
Open a terminal, navigate to the folder where you want to have you project file, and then run the command
qmake -project
This will search the current directory and all subdirectories for files with extensions such as .c, .cpp, .h, etc. (the full list is found by typing man qmake).
But keep in mind that it will overwrite your current .pro file if you already have a project set up.
qmake provides a convenient files function for this very purpose. Adding the following line to your project file will add .cpp files inside the src/ directory:
SOURCES += $$files(src/*.cpp)
By default, this is non-recursive. Setting the second parameter to true recursively finds all files:
SOURCES += $$files(src/*.cpp, true)
The files function was introduced since Qt 5.10.
Nowadays you can just right click on project name and select Add existing directory

how to create header file and source file of a .ui file in Qtdesigner?

I have an application in which i have a mainwindow.ui file and i create a new designer file dialoge.ui in same application now how i can create source file and header file for dialoge.ui .I am using QtCreater(windows).
I am a beginner in qt , i think there should be a way for the same but i am not getting.
Help me.
Thanks
You can create source & header out of .ui file externally & then import them into your application(Dont forget to reference then in the .pro file.). Create a executable(.bat or .exe) to execute following commands. Below is the shell script(I am a linux user.)
echo HEADERS
<path to your uic compiler>/uic -o form.h form.ui
echo SOURCES
<path to your uic compiler>/uic -i form.h -o form.cpp form.ui
For each file somewidget.ui, during the build process ui_somewidget.h and ui_somewidget.cpp will be created. The tool used to generate them is uic.
All you have to make sure that the .ui files are added to the .pro file of your project, along with the other source and header files, like this:
FORMS += somewidget.ui
qmake/make will automatically generate and build the .cpp and .h files for somewidget.ui.
you can do this:
Save your dialoge.ui file in a directory.
Use qmake to create the .pro file (qmake -project), qmake is smart enough to detect the .ui.
This will also generate the appropriate makefile rules to invoke uic, Qt's user interface compiler.
If you are using visual studio, you can call qmake -tp vc, this will generate a visual studio project, linked and ready to use.
The visual studio project will generate a ui_dialoge.h for you, you can copy this to another project and use it in another header file which will use this dialoge.ui
I'm not sure I've completely understood your question. You have an application developed in QtCreator in which you have 2 .ui files. And you want to generate the corresponding header/source files to these 2 files.
Using QtCreator you don't need to worry about generating header files. This is done automatically. During the build phase, the User Interface Compiler (uic) is called and translates the .xml files into c++ header files.
Additionally to the already correct answers: change from Debug to Release mode in the general settings. In my case, the header file wasn't created in Debug mode

Play a WAV file on Symbian with Qt (QSound)

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.

How to set Application Icon in QT on WinCE?

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.

How to set Application Icon in QT on Symbian?

How can I set an app icon in QT on Symbian? I read here http://doc.qt.nokia.com/4.6/appicon.html about hot to set it but it doesn't work for me. I created SVG-Tiny icon(file) and wrote ICON = Resource/ico.svg in the pro file. What is wrong?
Thanks in advance
That should do it. Works for me. Things to check:
Have you run qmake and rebuilt the project after editing the .pro file?
In emulator environment, have you restarted the emulator?
Check that your PKG file has rules to install both yourapp.rsc and yourapp.mif to \resource\apps on target
you need to give the path of icon in your .pro file like this
ICON = Resource\ico.svg
i hope it helps.

Resources