Remove the "Customize Quick Access Toolbar" button - c++

I'm working on a project where we want to have a quick access bar that is unchangeable/static. We've looked at inheriting from the CMFCQuickAccessToolbar and removing that button, but those attempts seem fruitless. Just getting rid of the button completely gets rid of the toolbar. Anyone have some experience with this, or an alternative approach?

After a lot of headache we found that there was no clean solution to removing just that button from the toolbar. Instead, we opted to place the buttons we wanted to display in the quickaccess bar in the tabs group. These button will appear on the right side (beside the help icon in word). To replicate the look of the QA buttons, I had to create an imagelist and load our buttons into it.
CImageList theList;
CBitmap bm;
bm.LoadBitmap( IDB_QASMALL );
theList.Create(16,16, ILC_COLOR32 | ILC_MASK, 5, 0);
theList.Add(&bm, RGB(192,192,192));
I then created ribbonButtons to be added to the tabs group, with the proper command IDs, empty text, and the proper icon from my image list.
CMFCRibbonButton* button = new CMFCRibbonButton( ID_SOMECOMMAND, _T("\na"), theList.ExtractIcon(<IconOffset>));
m_wndRibbonBar.AddToTabs(mp);
It's not a perfect solution, but it at least gives us a similar UI without the worry of getting rid of that stupid customize button. You also have the freedom to use labels on your buttons.

Related

Hide label text for Qt tabs without setting text to empty string

I need a QTabWidget with icons only:
How can I hide the label text of a tab in Qt? I cannot set the text to an empty string (""), as I am using docked widgets ( QDockWidget ) and the label text is set automatically (and I need it if the widget is floating).
But in tabbed mode I just want to display the icons (of the tabs).
Possible approaches:
Font size to 0?
I need to create my own bar class and override the paint event as here
Anything easier / cleaner?
--- Edit ---
Ok, the "set window title to empty string, and reset it the original text" approach works. I am using the topLevelChanged signal for this. However, it has some drawbacks, as the empty text still occupies some space. Another issue, with the text the tooltip is gone, and I cannot set it back.
What I am currently trying is something in-between the "text empty" and Prasad Silva's approach. I try to identify the text label inside the tab and set its size to 0, then reset it. It's slightly different, but would keep the text intact.
Btw, I see a line on top of my tabs, any idea what this is (where it comes from)?
Edit: There seems to be no "easy way" (style sheet, attribute) for this, see Hiding bottom line in QTabBar
Maybe I will create the whole tab bar on my own, as the automatically generated stuff is just too hard to handle (agree with PS on this).
This can not be done easily. Use empty text.
The way I solved something like was to create a QDockWidget subclass that installed a QWidget subclass as the titlebar (via setTitleBarWidget). This gave me control over showing/hiding the text in the titlebar when the dock widget fires topLevelChanged, dockLocationChanged and visiblityChanged.
This is really a big hack to get around the fact that Qt has refused to expose a public API for the docking system. We have since moved on to a custom docking implementation due to these limitations.
If you do not want to see the text, you can set it to an empty text after saving the current text, and when you want to see it again, restore it from the stored variable.
I do not think there is anything in the API for this not so common case, which means you will need to do it yourself.
Now, you could claim that it is tedious to do for many widgets, but on the other hand, you could write a simple hash define or inline function to do this repetitive work for you, which would only result a one-liner call, basically, which you would need to use anyway when changing the state.

How do I keep a button depressed in C++?

I want to create a navigation panel in my C++.net application, and I want to keep a button (or similar component) depressed to show that is the page the user is currently on.
Here is a image of what I mean:
How do I create a button that looks like that. (After further inspection, I think it's not a button, however, I cannot figure out the exact control unless it is a image drawn on the screen.)
Thanks.
That is commonly called an "Outlook Bar". There are several examples at codeproject.com

C++ MFC CComboBox is empty

i've a little comboBox, and i want to fill it with 6 entries... .
i wrote this code:
CComboBox* dropdownList = ((CComboBox*)GetDlgItem(IDC_PROGRAMDROPDOWN));
dropdownList->Clear();
dropdownList->AddString(L"test");
dropdownList->AddString(L"test2");
dropdownList->InsertString(2,L"test3");
dropdownList->InsertString(3,L"test4");
dropdownList->InsertString(4,L"test5");
As you can see I tried AddString(), and InsertString(). both with no effect. I also tried it just with AddString() which should be the correct way at initializing it.
But, my combobox is empty. I already debugged it, and this lines are hit but with no effect.
Do you have any idea?
In the dialog editor, make sure you resize the ComboBox item so that its height is big enough to contain all of the items when the ComboBox is expanded. By default, it'll only be the height of the "edit control" bit of the ComboBox, which limits the expanded height.
So, in the dialog editor, click on the dropdown button bit of the Combo Box and you should see the drag handles change a bit. Drag out the new size to account for all the items in the dropdown list.
thanks for all your answers. But it was an ugly Failure by my IDE -.-. I just recreated the UI-Element and it worked...
I recreated it with the same properties (Copy & Paste)

create a scrollbar in a submenu qt?

I have a map application and a submenu which has dynamically added objects (i.e. points on a map) added to the submenu, depending on the layer that is loaded. I have the ability to hide each individual objects (i.e. a point) by clicking on the corresponding submenu item. Is there any way to organize the submenu? When there are a lot of points (i.e. 100) the entire submenu takes up the screen. Can I add a scrollbar to a submenu? I looked in the documentation, but couldn't find anything that support this feature.
From this bug report I was able to find out that you could do the following:
submenu->setStyleSheet("QMenu { menu-scrollable: 1; }");
Works like a charm.
There is no such possibility as far as I know.
Maybe you shouldn't use a sub menu for this but prefer a menu entry that show a Point manager GUI of your own which would have a QListWidget displaying all your points items.
I'm aware that this solution will break a (big?) part of your code but I don't see anything else.
I think you may be able to get the effect you want by creating and using your own QStyle subclass (via QApplication::setStyle()), and overriding the styleHint virtual method to return 1 when the StyleHint parameter passed in is SH_Menu_Scrollable. At least, that works for me when I create large QMenu objects and show them as popup menus.... It may also work for QMenus attached to the menu bar, but I havent tried that.
Whilst it is possible by subclassing the QMenu class to create a custom widget and going from there you're better off looking at a better way to display that information. You'll save yourself time and it'll be much easier for your users to not have to scroll through a big list of items in a small area.

Adding drop down arrows to CMFCToolBar buttons

Can anyone explain how to add dropdown arrows to CMFCToolBar toolbar buttons - like for undo/redo buttons. We had this with CToolBar by using the TBSTYLE_EX_DRAWDDARROWS style and TBN_DROPDOWN notification. This doesn't seem to work with CMFCToolBar. These dropdown arrows i believe are added to the VisualStudioDemo MFC feature pack demo but i can not figure out how.
In the VisualStudioDemo sample, in CMainFrame::OnToolbarReset they replace the Undo button of the toolbar with a custom class called CUndoButton, like this:
m_wndToolBar.ReplaceButton(ID_EDIT_UNDO, CUndoButton(ID_EDIT_UNDO, _T("&Undo")));
CUndoButton is declared in file "UndoBar.h" of the sample project, so you can use it or change it however you like.