Qt setWindowTitle on Mac does not change icon in dock - c++

The problem appears when I try to build a single binary on Mac. It is working fine when building my application as a bundle. Then it just takes the icon defined in the info.plist.
Another thing is that I want to avoid displaying my application icon in the dock at all? Any way to do that?
I need a solution for one of the issues, either show a custom icon in dock, or don't show any icon.
Have somebody had the same issue and maybe found a workaround or solution?

Related

How to create an Evernote kind of widget for global menu of a MacOS/X desktop using QT?

How to create an application which stays in top of MacOS, something similar to below image. You can see the Evernote elephant icon.
I don't want to use xcode - because my application already built in QT, it has nice GUI, now I wanted to add extended feature something similar to Evernote. If I click on an elephant it will open a dialog box to write notes. In my case- it's a simple event like on/off buttons.
I have tried and created GUI widget apps but how to make one which resides like Evernote app ?
A custom pop up menu like the one pictured can be done several ways in Qt.
QML is the most modern way of making the menu with the customized styling you are looking for.
Apply the appropriate flags to the window/widget so it appears as a popup.
The same effects can also be done in QWidgets, but takes more code and probably will take longer to make. The flags you are looking for will be found under Qt Window Flags and/or under Qt Widget Attributes.
The stock stylings for Qt for different OS's deal mostly with title bars, status bars, buttons, drop downs, etc.
The base styles for Mac can be found here:
http://doc.qt.io/qt-5/gallery-macintosh.html
Once you go to a customized popup, you have to draw all of it yourself... but the native drawing elements in Qt are friendly enough and get you that look you are trying to do.
There are even some tools for exporting from Photoshop or Gimp directly to QML.
http://doc.qt.io/qtcreator/quick-export-to-qml.html
Hope that helps.
You are looking for a tray icon. Qt implements it in QSystemTrayIcon.
Further information
You may take a look at the System Tray Icon Example.
Many StackOverflow posts exist on this topic.
If you already have a program written for Qt, then you can compile and run it under MacOS/X much the same way you could compile it under (whatever OS you're using now). You'll need to install Xcode because Xcode includes the C++ compiler (clang) you'll need in order to compile your Qt program, but you don't have to use the Xcode IDE if you don't want to. Rather, you can either use the QtCreator IDE under MacOS/X, or you can simply open up a Terminal window and do a "qmake ; make" in the directory where your Qt-based program's .pro file is, and build it from the command line that way.
If, on the other hand, your question is actually about how to add an icon to the global menu of a MacOS/X desktop, then I don't think Qt has an API for that, so you'll need to drop down to using one of MacOS/X's native APIs. That will probably involve learning some Objective-C (or Objective-C++, if you prefer), but integrating a bit of Objective-C/C++ into your Qt app is doable with a bit of work.

How to Set Desktop shortcut icon different and task bar icon different for a QT Windows application?

I need to set title.ico as my application icon and shortcut.ico as my desktop shortcut. Is there any way to do it in a Qt application itself while building?
Whenever the user right-clicks on my application and clicks on sendto->desktop(create shortcut), the shortcut should have shortcut.ico. But now it's always displaying title.ico.
I checked WinApi IShell_link but it didn't help.
I am also a beginner, but turns out this is possible. See this thread: https://forum.qt.io/topic/45324/taskbar-icon-different-from-the-icon-of-the-window/8
Hope I understood you right. Enjoy!
Edit 2018-03-13:
Create your icon in diffrent sizes (e.g. 16px, 32px, ...) as an .ico (while on Windows), for further information visit: http://doc.qt.io/qt-5/appicon.html
Call QWindow::setIcon() (http://doc.qt.io/qt-5/qwindow.html#setIcon)
Profit. The icon should now be visible in the greater resolution in the taskbar, while the smaller one is choosen for the app window.

qt form fullscreen sometimes goes over the ubuntu top pane and sometimes not

I am writing an QT application that embeds Mplayer on Ubuntu unity. I want to project videos on a projector in a dance show. I therefore have created a second form, which I move to the second screen and make it fullscreen.
Here is how I did it:
void MainWindow::on_testdialog()
{
QScreen *secondscreen = QApplication::screens()[1];
outputform->move(secondscreen->geometry().x(),secondscreen->geometry().y());
outputform->resize(secondscreen->geometry().width(),secondscreen->geometry().height());
outputform->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
outputform->setWindowState(Qt::WindowFullScreen);
outputform->show();
}
Then I redirect the Mplayer output to this form.
This works, however sometimes the second form is true fullscreen and sits on top of the Ubuntu unity menu pane (the one on top) and sometimes the Ubuntu unity menu pane is on top.
It seems to me that it is randomly doing this.
I would like my form to be always on top, because I don't want the menu pane to show up on stage.
Is there a way to do this?
Is there a reason for this, seamingly, random behavior? maybe a bug in Ubuntu?
Kind regards,
Bart.
This sounds like a problem of the window manager which makes it out of reach for Qt to solve. Qt is only setting the corresponding WM hints on the window and hopes for the window manager to do the right thing.
For your application I suggest you install a lightweight window manager like Openbox or Fluxbox that will more likely stay out of the way. After installation you can choose it in the login screen.

GLUT_ICON not working on top left window

am trying to add an icon application that uses freeglut, according to the doc here it seems is enough to have an icon resource GLUT_ICON.
Although it worked, it only appears on the icon of the console window and the executable in windows explorer, but the main window remains with the default windows icon (as shown in the image). I tried building without the console window mode, but I get same behavior, is this the way it suppose to work or am getting a wrong behavior?
This might help clear things for others running into the same problem:
https://www.gamedev.net/forums/topic/151647-opengl-glut-icon/
Basically, in the "file.rc"resource-file (right click view code) that appears after adding an ico resouce, where you should have
MAINICON ICON "compiler_assets\\icon-name.ico" //set main icon to "file"
You should add another line
GLUT_ICON ICON DISCARDABLE "compiler_assets\\icon-name.ico"
Which is basically setting GLUT_ICON to a specific .ico file
Finally fixed this problem. Whether this issues come from the VStudio2012 environment or not is uncertain.
But generating the resource id like this; GLUT_ICON creates a non-defined behavior. The exe is unable to identify this tag as a valid one, therefore no icon can be indexed and found.
By just changing to lower case the string, all problems get fixed.
I did this process manually and the fix seems to be consistent between PC's.

Carbide / Symbian C++ - Change Application Icon

I am using Carbide (just upgraded to 2.0) to develop an S60 3rd Edition application.
I would like to know the easiest way to change the icon (both the application icon on the device menu and the icon at the top left of the main view) because I have the need to skin my application in many different ways as easily as possible.
All my efforts with messing around with .mif files have so far failed. I have a 44x44 .svg icon I made with Illustrator, could someone please help me in the right direction?
Thanks!
To change the app icon when you run your app use (in the status bar):
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
CAknContextPane* cp=(CAknContextPane *)sp->ControlL(TUid::Uid(EEikStatusPaneUidContext));
_LIT(KContextBitMapFile, "my_bitmap_file.mbm");
CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(KContextBitMapFile, EMbmBitmap);
CleanupStack::PushL(bitmap);
CFbsBitmap* bitmapmask = iEikonEnv->CreateBitmapL(KContextBitMapFile, EMbmBitmapMask);
CleanupStack::PushL(bitmapmask);
cp->SetPicture(bitmap, bitmapmask);
CleanupStack::Pop(); // bitmapmask
CleanupStack::Pop(); // bitmap
DrawNow();
I'm not aware of any possibility of changing the app icon in the menu list programmatically, other than reinstalling the app with different mif file.
If you want to change the icon in your SIS file and then overinstall it on device then you may have to reboot your device after installation - the application icon is in the Symbian cache and is not updated.
http://wiki.forum.nokia.com/index.php/CS000808_-_Creating_and_adding_an_icon_to_an_S60_3rd_Edition_application
With latest QMake and Qt SDK (4.6.2) you don't need to create any .mif file yourself. An SVG file will do.
For more detailed instructions see: How to Set Qt Application Icon and Title in Symbian S60.
Although the article uses Qt Creator, as long as you use QMake then it's the same thing.