How to set Application Icon in QT on WinCE? - qt

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.

Related

Is it possible to use Qt VS Tools to work on a cross-platform project and have it automatically keep project changes synced in a .pro file?

I am trying to understand what the intended workflow is when using Qt VS Tools to develop a cross-platform application. If I have per-platform options in the .pro file, does that mean that I must manually keep the .pro file in sync with the .vcxproj file when working on Windows not using Qt Creator?
For example, I have set up a test project and implemented a little desktop application using Qt VS Tools. I can now select "Create Basic .pro File" from the Qt VS Tools extension menu. This will create the following .pro file which I can build and run from Qt Creator:
TEMPLATE = app
TARGET = TestQt
DESTDIR = ../x64/Debug
QT += core gui widgets
CONFIG += debug
DEFINES += _UNICODE _ENABLE_EXTENDED_ALIGNED_STORAGE WIN64 QT_DLL QT_WIDGETS_LIB
INCLUDEPATH += ./GeneratedFiles \
. \
./GeneratedFiles/$(ConfigurationName)
DEPENDPATH += .
MOC_DIR += ./GeneratedFiles/$(ConfigurationName)
OBJECTS_DIR += debug
UI_DIR += ./GeneratedFiles
RCC_DIR += ./GeneratedFiles
include(TestQt.pri)
Now say however I want to make the project have some platform-specific dependency. As an example say I add the following before "include(TestQt.pri)" in the above -- but this could be any kind of manual edit to the .pro file.
windows {
SOURCES += WindowsSpecific.cpp
}
This will work in Qt Creator but I would have to manually add the new file in Visual Studio. If I now add something platform agnostic in Visual Studio and rebuild the .pro file via the same extension menu item, I will lose anything that I manually added to the .pro file like the include of WindowsSpecific.cpp above.
So is the intention that I create a .pro file once and from then on manually edit the .pro file to keep it in sync with the Visual Studio project or is there some automatic way that I am missing.
I think there is no good way to do this.
A better workflow that solves the general issue, though, is to work in the reverse direction: add files and make project changes only through QtCreator / in the .pro file and when the project file changes sync Visual Studio by re-generating the .sln file with by opening the .pro file in Visual Studio via Extensions/Qt VS Tools/ Open Qt Project File.

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.

Base icon for a Qt application

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.

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