Tab order in Qt - c++

I have complicated UI created with Qt Designer. It has a hierarchy of nested widgets. I need certain tab order to switch between controls inside these widgets. But as far as I see, Qt designer allows to define tab order only within one widget. How to do it globally?

open the Edit menu and select Edit Tab Order. In this mode, each input widget in the form is shown with a number indicating its position in the tab order. you can click on the box number and change the priority.by right click you can see 3 options, start from here, restart and Tab order list.

Related

Nested comboboxes in Qt

I'm looking for a way of nesting comboboxes in my GUI application (or to be more precise, I'm looking for a way to have an item displaying similar visual and functionnal properties as nested comboboxes).
Looking first at all the functions provided by the combobox class, it seems comboboxes nesting it's not supported by Qt.
I therefore thought that another solution would be to create a "menu" item outside the menu bar. If I understand correctly this phrase from the offical Qt documentation, it seems to be feasiable :
A menu widget can be either a pull-down menu in a menu bar or a standalone context menu
Not sure though was is meant by the "context" word.
However, there is no such (menu) widget in Qt designer and I haven't found any good examples about how to do it on the internet (and can't get a menu not associated with a menu bar to be displayed on the windows), explaining why I'm currently doubting whether it's feasible or not with a menu item.
I would greaty appreciate if you could provide some code sample along your response.
EDIT :
To clarify my first post, I'm trying to do something similar to this app :
It's the application that comes along the 3D connexion mouse whose usage is to parametrize each button.
As you can see, there are several sub-menu items. By clicking on the arrow next to a textbox, you open a sub-menu containing itself folders that contains themselves paramaters.

Change content of a menu bar in different stack widget page in qt

Forgive me if this question is silly but I want to know
if there is a way to change the content of a menu bar in different
page on a stacked widget directly in qt designer.
For example I want the menu of the menu bar for page 1 of the stacked widget to be menu, inbox, multimedia, exit. For the second page I want the menu bar to contain the following menu; Text, outbox, contact, back. The reason is because
I want different menu controls for different pages of the
QstackeWidget. Is this possible from the qt designer ui or I'll have
to ultimately do it programatically?
As far as I know (which is QtCreator 3.3.0) the Creator only supports graphically inserting and editing a menu bar in QMainWindow. So for the first part of your question: Yes, you probably have to create the menus programmatically.
For the second part, it is possible to insert a menu bar in any given layout using QLayout::setMenuBar. This also includes the layout inside your stacked widget.
See also: Can you add a toolbar to QDialog?

How to create an editable list of items in Qt Designer?

I'm using Qt Designer to create a Qt 5.4 GUI application (actually, I'm using Qt Creator 3.3.2 but haven't done any C++ yet; everything is in the .ui file).
I'd like to create a box containing an (empty) list of items from which the user could double click inside the box to add a new element to the list (can be single click or other, doesn't really matter).
I just can't figure out how to do this only through the designer. I've checked the properties of the "List Widget (Item-Based)" and "List View (Model-Based)" and there is some options in "editTriggers", but even with the default "DoubleClicked" checked, the compiled application does not allow adding a new element (or deleting...)
Any easy way to achieve this using only the Designer (without doing C++)?
Or is there another widget that would be better suited for this?
Thanks!
If you want to make such a widget, that can be setup completely in the designer only, you are asking a little too much.
If you start with a List Widget and add a bunch of empty named elements, and then make all of them editable, it will seem like you can just double click to add an element.
To make an existing element you've added in the list editable, (in the designer) double click your List Widget, then
in Edit Widget List, click the plus sign, followed by Properties. Scroll down to flags, then check Editable.
This needs to manually be done for each item added.
The C++ to add what you are asking for is very painless.
Add a Push Button. Rename it's objectName to addItemButton.
Then right click on it, and select Go to slot....
Select clicked(), then click Ok.
Now put the following in the slot:
void MainWindow::on_addItemButton_clicked()
{
QListWidgetItem * item = new QListWidgetItem("New Item");
item->setFlags(item->flags() | Qt::ItemIsEditable);
ui->listWidget->addItem(item);
}
Done.
Hope that helps.

the combobox dropdown list is so small that an updown arrows appear beside it

I have comboboxes that was built on the OWL I moved them to MFC and I faced alittle problem, the dropdown list of the combobox is so short that it shows only one item and you can navigate to the other items by using udown arrows like in the picture
the image on the left shows the short and incorrect one, the one on the right shows the release version that is working well.
what can cause this problem? and hoe to fix it. think it is style issue
Open dialog template in Resource Editor. Select combobox by mouse. Click on the "Down Arrow" element in the right part of the combobox (in your case it may be left part, according to localization). Then resize the combo to required height - in this state it resizes dropdown list. Build application and test dropdown list height at runtime - it should be OK.
http://msdn.microsoft.com/en-us/library/vstudio/4cta1x1t.aspx
See also: CB_SETMINVISIBLE message - allows to resize dropdown list size programmatically. I have never use it in my programs, though, so this is just a hint.

Hide a tab previously added to Qt TabWidget

I've a dialog which contains a Qt TabWidget with a number of tabs added.
I'd like to hide one of the tabs.
_mytab->hide()
doesn't work. I don't want to just delete the tab and all its widgets from the .ui file because other code relies on the widgets within the tab. However, it would be fine to generate the tab code but somehow not ::insertTab in the generated uic_mydialog.cpp. Setting the hidden property in the ui file does not work either.
I'm using Qt 3.3
I had encountered the same problem. I am using the following approach.
Now here is the data.
genTab is the name of my QTabWidget
tabX is the name of the tab that i want to remove.
(Note that this is the second tab in the Tab Widget. Hence, i will be using "1" as the index to refer to this tab)
The code to remove and add is as below.
ui.genTab->removeTab(1); // removes the tab at the index 1 which is the second tab from left
ui.genTab->insertTab(1, ui.tabX, "<Name of TabX>"); // The tab is added back.
Here, note that it is easy to do this if you have the tab added statically in the design time. Because we will have an object name associated with the tab and hence we can refer to it using, ui.tabX. From what you say, in your case the tab is indeed added statically in the design time.
However, if you are adding the tabs dynamically, then probably you will have to maintain the tabs in a list and then have another list for deletedTabs.
But the first solution will most likely work for you.
Hope this helps.
-Arjun
I would use QTabDialog::removePage(QWidget* pTabPage) which does not delete pTabPage, which is what you want.
_myTabDlg->removePage(_mytab);
I'm using it and it works fine !