QT strange GUI Components: Tabs? - qt

I saw once someone making the GUI in QT and he had something I have never seen until now: They looked like big buttons one after another and when you clicked on them, the buttons below were going down, making space for the dialog or tab. It was like, if you click on the button "Draw", suddenly below the button a tab or a dialog or ??? appeared with all the GUI components (radio buttons, listboxes, ...) that you need for draw. When you clicked on another button, this GUI disappeared to make space for another GUI. Does anybody know what it is?

Qt does support tabs.
They are actually different widgets you can switch from in the same window.
Here you can find an example on how to use then: http://qt-project.org/doc/qt-4.8/declarative-ui-components-tabwidget.html
Inside a tab it's just like a normal widget.

Related

Show a QT UI in another one

I have a project including 3 UI files: win_main.ui, win_table.ui and win_table2.ui.
I want to show one of them inside of win_main.ui, and with a button, change them.
I mean, there is a Box containing win_table.ui, and when I clicked the button, the box will change to win_table2.ui.
Example
I tried using QWidget, QQuickWidget, but they didn't worked.
Is it possible ? If yes, how ?
Try using a QTabWidget. You can flip between tables using tabs.
If there is a specific reason why you wouldn't want win_table2.ui showing before a button is pressed, you can disable that tab programmatically until it is ready. You can also flip between which tab is currently showing using code as well.

Popup Windows in Qt

I am very new to programming and Qt so please be patient with my ignorance. I have spent two days searching for an answer and I can't figure out where to start.
I'm using Qt 4.8.5 and I would like to create a program that has a mainwindow with a few icons that will open frameless sub windows when clicked.
I've played with the window flags example but none of the options seem to meet my needs... the popup widget is close but I don't want the sub window to disappear when I click on something in the main window. All the other widgets like window and dialog cause the mainwindow to lose focus (not sure this is the right terminology).
Is there a way to make a popup window stay open until the icon is pressed again or use another kind of widget but keep focus on the main window?
I'm sorry if this question is poorly worded.
If I understand correctly what you are asking, you could use setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); on the widget you wish to use as a popup window. It will give you an always on top frameless window.

in Qt how to know which component (placed on a widget or form ) is currently focused?

I am doing work on Qt. i am not using android. It's just a desktop application running on windows/linux.how to know which component (placed on a widget or form ) is currently focused ?
i have onscreen keyboard which appears when a QLineEdit,QTextEdit or QPlainTextEdit get focused and hide when these lost focus.But when i switch focuse from one TextEdit(or lineEdit,PlainTextEdit) to Another TextEdit(or lineEdit,PlainTextEdit) my keyboard hide and again show.I just want to stop this
If you want to stop the keyboard from flickering when the widget it's coming from and the one it's going to are similar then you could perhaps implement a timer. I imagine you have the lost focus signals going to your code that is hiding the keyboard. Instead of really hiding it, you can start a timer like
QTimer::singleShot(500, this, SLOT(really_close_keyb()));
Within that really_close_keyb() slot you could implement code to check if the widget that currently has focus should have a keyboard or not, and if it should then you don't hide it.
With this your keyboard will be up for 1/2 sec after the user focuses out of a line edit, giving enough time to focus on another one without losing the keyboard. Adjust the timing to suit.

Showing when a button has been pushed in Qt

I'm using Qt with C++, and I want to make a button that keeps looking pushed down after it is pushed and released. I'm currently making buttons on a QToolBar and doing something like toolBar->addAction (icon, tr("Text"));. This makes buttons on the toolbar that display the QIcon named icon and display "Text" on hover-over. They also look pushed down as the user is pushing them, but stop looking pushed down when they are released (as is reasonable for most uses of buttons). I need something different, however: I would simply like the buttons to remain looking pushed down after they are released, perhaps until they are clicked again. It would be best if I could just call some function on a button or on the toolbar that could give me the capacity to control whether a button will look pushed down or not pushed down when it is displayed. That way I could just control this aspect of button appearance programmatically.
What's the easiest way to do this in Qt? I've seen fancy ways of doing it involving borders and very complicated setups, but I was wondering whether there might be an easy way to do it.
Add QPushButton to the toolbar using addWidget and then make the button checkable.

What is the proper name for a multibutton?

I'm trying to design a UI in Qt and I can't find anywhere in the designer a button which can be "droped down" like combobox. What I mean by that is that I would like to have this button with his "default" option choosen so if I like it I would have to just click on it but if I would like to choose different option I would be able to clik the little arrow on the right side of this button and then pick option suitable for me at that moment.
You're looking for a QToolButton that has a set of actions or a menu set on it. From the documentation, the QToolButton::ToolButtonPopupMode...
Describes how a menu should be popped up for tool buttons that has a menu set or contains a list of actions.
Of it's values, the two that I see most frequently are DelayedPopup:
After pressing and holding the tool button down for a certain amount of time (the timeout is style dependant, see QStyle::SH_ToolButton_PopupDelay), the menu is displayed. A typical application example is the "back" button in some web browsers's tool bars. If the user clicks it, the browser simply browses back to the previous page. If the user presses and holds the button down for a while, the tool button shows a menu containing the current history list
And MenuButtonPopup:
In this mode the tool button displays a special arrow to indicate that a menu is present. The menu is displayed when the arrow part of the button is pressed.

Resources