Hide Page/Tab from QTWidget - QT 5.5 - c++

i need to hide tabs from a existing project in QT, i don't want to delete the code because i have to set parameters on that code, the Application relay on that too. Seems like QT hasn't built-in hide(); function, i tried to edit stylesheet to make it smaller, but doesn't work too, i've looked on the internet and seems like this is a known issue. Does somebody have some tricks to avoid this?
Only thing i was able to come up with is:
ui->TabObject->setEnabled(false);
basically i disable objects in the tab to make them not usable by the user, but this is not a good thing for the whole UI.

Maybe by calling QTabWidget::removeTab(index) - this removes the tab from the QTabWidget, but does not delete the tab's QWidget.

Related

Disabling a ComboBox item in Win32 API

I would like to disable an item in a combobox in my Win32 application (C++). I'm not quite sure how to do this. I'm trying to achieve something that looks like this:
Notice how CollectionItem2 and 3 are greyed-out.
Any help would be very much appreciated!
If you truly need a combobox for this, then (as #IInspectable said) you'll need to do a custom drawn control. Basically, you'll have to store some information saying which items are disabled/grayed, and draw the items appropriately based on whether they're enabled or not.
There may be a somewhat easier way though. This is normally done with a Split Button. This is button with the BS_SPLITBUTTON style set. When the drop-down part of the button is clicked, it sends a BCN_DROPDOWN notification.
You normally respond to that by displaying a menu, typically using TrackPopupMenu to display it immediately below the button (or immediately to its right, if you prefer). This is a normal menu, so it can have items enabled, disabled, grayed, have check boxes, etc., as you see fit.
If you're using MFC, it has a CSplitButton class that wraps the Split Button, simplifying the code a little bit--you can pass an identifier of a menu and sub-menu when you create the CSplitButton object, and it handles things from there.
A sample result probably looks pretty familiar:
Note: MFC also has a CMfcMenuButton class. This has roughly similar functionality, but is somewhat clumsier to use. If memory serves, it is compatible with older versions of Windows (but the split button goes back to Vista, so it's fine unless you really need to support XP).

Add some text to a QToolBar

I am having trouble adding some text in a QToolBar. I can only add Actions. Also I have two actions with their rerspectives icons in my QToolBar but I want to separate them and I canĀ“t either.
My newbie approach was to add empty actions to simulate blank spaces between the icons. But the user can click on the blank spaces.
I am using the Design function of QT Creator. Some help would be really apreciated.
It looks like you can't do it from within Designer:
https://bugreports.qt.io/browse/QTBUG-1267
That's an oooold suggestion, too, with a low priority to boot, so it probably won't get fixed any time soon.
You can get your hands dirty and do it in code, however.

Qt - How to create extra roles for a QDialogButtonBox

I apologize in advance for not having more code to show, this is more of a conceptual question. I am working in Qt 4.7 and I have a QDialogButtonBox in my UI to which I need to add several custom buttons*. I set the buttons up like I normally would. For example, if I'm adding a Save button, I would create it like this:
QPushButton *myButton = new QPushButton(tr("Save"));
Usually I could just add this to my UI as is. However, I've found with the button box, it needs to have a "ButtonRole" attached, which are built-in to Qt. The only role that seems close to matching what I want is "ActionRole", but that's still sort of vague as to it's meaning when looking at it later in the code. I know theoretically any of the roles could be associated with this button, but it seems like really bad practice to me to attach an unrelated-named role like "RejectRole" or "HelpRole" to it just to make it work. My question is, how can I create a new role, something like "SaveRole", that I can use for this button? I tried putting a line like #define SaveRole (some int value) in my code and using that since the ButtonRoles are enumerators, but that gave me an error saying it couldn't convert the parameters. I know there's also NRoles in ButtonRole, and it seems like that can probably be used to create new Roles, but I've been searching for about a half hour and am finding it EXTREMELY difficult to find any information on how to use this. If anyone has suggestions it would be greatly appreciated. Thanks!
*For the record, I know how easy it would be to avoid this problem by using QPushButtons individually instead of a QDialogButtonBox, but my project head wants the button box used, so unfortunately I don't have that option.
EDIT: I forgot to mention before but it may be worth bringing up, this button box is pretty large, and all the built-in roles are already in use.

How to display list of opened tabs in Qt 4.8 on Ctrl+Tab

Is there any straightforward (without listening to key events) way to display the list of opened tabs in Qt, like following (in Visual Studio). I just want to make sure Qt does not offer such a feature, before implementing such a widget by myself.
At least in a primitive way like in NotePad++ (meant no offense). Now, when I am using QTabBar and press Ctrl+Tab it shows something like this,
And I don't know actually what is that !
The default behaviour of ctrl-tab is to cycle through the tabs. You will need to customize that to display your own dialog. You don't need to connect to any signals to do this, simply pass a reference to the tab widget/bar into the dialog. You can then use that reference to retrieve the names and to change the tab.

wxSmith a good way to manage wxPanel

I have a project where I'd like to have many wxPanel which are displayed or hide, depending the selection of the user. All panel are on the same position, only one is displayed at a time.
On a code side, there is no problem at all. Where it gets tricky, is how to manage this with wxSmith and keep a clear view while having many wxpanel at the sample location?
One way which is really not proper is to user the wxNotebook, and then when you start the soft delete all tabs and then show the needed panel.
I have look around to try to have the panel on a "other" wxSmith window and then load it, like a class but haven't find anything good.
I'm sure, as wxSmith is really a great tool that it must have a way to do this.
Thanks for your help!
See ya
"One way which is really not proper is to user the wxNotebook, and then when you start the soft delete all tabs and then show the needed panel."
Why not? I use that technique for AtomWeaver, and it works fine. The plus side is that you can design each page normally on a RAD GUI builder.
I've created a class called GUI_NotebookPageData that holds a pointer to a single notebook page. Create an array of these, holding info about all notebook pages.
Then, by index, or by name, get the info of the page you want to show/hide, and use wxNotebook's RemovePage()/InsertPage() methods.
This method is specially good for having several pages shown at the same time.
Actually it's possible to use external ressources with wxSmith, then it's very simple to manage the frames.
It create a derived class from wxPanel (or other window) on a new wxSmith window, easy to manage then just required to include it on the project.