How to add 'About' application option to menu in the qt application?
-
I have simple dialog based qt application. I want to assign and display application version but there is no standard menu to get to the version dialog. When I click the appliation icon (top left of application), it drops down the menu but 'About' <myapp> is not there. How do I add one and implement it?
I know I could do QMessageBox::about to show the information, where is the menu item to implement?
-
Without seeing your code I'm guessing at best but when you are looking at your form in the Qt Creator editor (if you are doing it that way) the menu bar is at the top.
To put items in the menu you use the "Action editor" at the bottom. To me its a little backward. First you add an action, then you have to drag it from the action editor up to the menu bar and it will change to used.
Once you've done that you can right click on any of the actions in the Action Editor and select goto slot. Triggered() will take you to code where you can implement a call to your about box.
BTW I don't think there is a default or standard about box. I could be wrong. I think you have to design one.
It is possible to put your application version info into your app. Again I don't know if you are on *nix, mac or Windows.
-
I am not using any menu bar or toolbar. I was referring to the application icon itself at top left corner in windows 7. If I right click on it, a system drop down menu appears. I thought it also used to contain 'About <this app> option but its not there and I was wondering if I can add one there and how? That would do the trick, I can than bring up my own dialog to show version.
-
Ok I don't think Windows has ever had about in that system drop down. There might be a way to add it. I think you'd need to explore the system calls in Win API. Once you figure out the handle of the menu you potentially could add to it. I've never tried it though.
-
The system menu is most definitely not the place to put an about entry. This would be highly non-standard and very few people ever open it. Even less people would ever think to look for any app related menu items or about entry there.
The usual place to put it is in a Help -> About menu in the top app menu bar. If you're not using any and don't want to create it for this entry then a dedicated button will be far more discoverable to the user.
As SysTech mentioned there's no way to extend the system menu using Qt classes (like QAction), as this is a frame controlled by the OS. A starting point would be the "GetSystemMenu":https://msdn.microsoft.com/en-us/library/windows/desktop/ms647985.aspx function, but again, I can not discourage you hardly enought from doing that.