Qt hide QToolBar and access shortcuts - c++

I am using Qt version 4.8.6.
I am trying to develop an application where only couple keyboard keys are used, without mouse. I have added some actions to my main QToolBar and assigned shortcuts to those actions.
Now I can either click on them or use the assigned keyboard keys to trigget the "triggered" signal. This is a debug feature however and in the end I would like to hide that toolbar. So to test it, I have used:
ui->mainToolBar->setHidden(true);
Toolbar dissapeard as I intended but the problem is that my assigned shortcuts stopped working. Is there a way to hide the toolbar but keep the actions shortcuts?

Related

Setting a window menu with set_menubar(), is there an 'activated' signal I can connect to run custom code when a menu is opened from the bar?

Gtk 3.0 application (with C++ and GtkMM). I use set_menubar() to set the menu bar for the main window (loaded from a resource file, i.e. a "*.ui" XML file).
At run time, I want to be able to enable/disable (gray out) menu items in accordance with availability. I know that I can use "add_action()" and "remove_action()" to associate/dissociate the actions, which will have the desired effect. However it is complicated and expensive to add/remove the actions dynamically considering that the only time it matters which actions are available is when the user has opened the menu and is looking at it.
So I was thinking that I should be able to connect to an "activate" signal of the menu bar items to adjust the appearance of their menu each time the user clicks on an item, just before the corresponding menu is displayed to the user. Any idea how I can get to the signal from the Gio::Menu resource? Is this possible in theory but an unfortunate omission in the Glib API? Or is there something I don't understand?

Display and use the same MFC CList control in multiple dialogs

I am coding a test application for a windows CE device. This is the first time I am programming for a handheld device. I use MFC VC++ on Visual Studio 2008. I have found that there are many restrictions in the controls and what I could do with them when running the program on a handy versus when I run a similar program on a desktop computer.
Now, the device I am currently deploying my test program to, does not have a touchscreen and has few extra keys other that the numberpad 0-9 keys. So, I have to do with a simple GUI that uses keydowns to call specific functions like add, edit, delete etc... It also forces me to use separate dialogs for each of these functions so as to avoid unnecessary mouse cursor usage.
This leads me to my current problem: The 'ADD' dialog of my test app adds some user data to a CListCtrl that is on the 'MAIN' dialog. The 'EDIT/DELETE' dialog is to allow the user to select the desired data from its own CListCtrl and press the "ENTER" key, which thereby deletes the selected data from the 'MAIN' dialog's CListCtrl. Thus, both the main dialog and the 'EDIT/DELETE' dialog have CListCtrl with the exact same data. So, instead of having to use 2 separate list controls and using loops to copy the data to and fro among them, is there a way in which i could use the exact same CListCtrl (one and only one instance of the CListCtrl exists), but display it on 2 separate dialogs? This would remove all the copying code, as well as halve the amount of data in memory.
I tried passing a pointer to the MAIN dialog's CListCtrl to the 'EDIT/DELETE' dialog in hopes that I could redraw the control there, but in vain. I could call the RedrawWindow, RedrawItems commands, but they seem to have no effect in the 'EDIT/DELETE' dialog (I think it is because the control itself is not present on the edit/delete dialog). Any other suggestions?
You could temporarily change the parent of the ListCtrl using CWnd::SetParent to the EDIT/DELETE dialog, and set the position with CWnd::SetWindowPos to where you want to have it. When the dialog gets closed, set the parent back to the MAIN dialog.

How to make customized widgets take keyboard events like textctrls

Platform Windows
Created a control using windows API: CreateWindowExW and set it's parent to a panel hwnd
But it seems the control does not handle arrow keys, enter keys and tab keys properly.
Is there any flag on wxwidgets give any control created by CreateWindowExW the same ability like edit controls to capture arrow keys, enter keys and tab keys?
The problem might be due to not using WS_EX_CONTROLPARENT for your control when creating it, this style is needed for the built-in tab navigation to work.
And while I don't think it's going to help with your particular problem, I'd still like to say that embedding a native control in an application using wxWidgets is not quite as simple as just giving it the HWND of an existing control as parent, you may want to look at wxNativeWindow (new in wxWidgets 3.1.0) for how to do it correctly.

How to add elements to the application menu in OSX?

Is it possible to change the Application Menu on OSX?
The default application menu looks like the following:
But most applications provide things like the about window in the application menu to not clutter the help menu:
How can this be done in Qt? A solution in QML would be great, but there isn't even a general solution in the project examples.
To force action into the application menu, set a menu role on it:
action->setMenuRole(QAction::ApplicationSpecificRole);

Programmatically and completely delete button from MFC toolbar

I have a document within MFC C++ application. I need to delete one the buttons from the particular CMFCToolbar within a code (not resources) completely, even preventing a user to restore the button via toolbar customization dialog. At this moment I use RemoveButton method of CMFCToolbar but it only makes the button invisible and it can be restored via toolbar customization dialog that is not an option for me at this time. I will be very glad if you suggest something that can help me there.
There are two internal lists in CMFCToolBar that are used to reset the Buttons upon customization.
They are named m_OrigButtons and m_OrigResetButtons.
You may need to derive your own class and delete the buttons with the specific IDs from there.
But better: Never to include such a button on the first time when the toolbar is created!