Expandable "statusbar" in Qt (QtDesigner)? - qt

Basically, what I want to implement is, a sort of an "expandable statusbar" (not sure if there is another name for it); in essence, in "collapsed state", it would be just a plain statusbar, able to show text strings/messages - except it has a "button" for expanding, here a "+":
When the expanding button is clicked, then the statusbar expands into a panel, covering about 1/3rd of the window (however, not "pushing" the preexesting widgets in the window, just covering them) - and the button changes into a "-":
Of course, then I'd want different widgets in the expanded state panel; likewise, if here I click on "-", I go back to the collapsed statusbar state.
I was wandering:
Is there already an existing widget in Qt that would be especially applicable to implementing something like this?
If not, is it possible to somehow implement this widget with existing QtWidgets, such that: at least the collapsed state is shown in QtDesigner UI, - and toggling between collapsed and expanded state is shown in QtDesigner Preview (that is, without a standalone application)?
If previous is not possible - is it possible to code a custom widget (in a form of a .dll, maybe?) that, when imported in QtDesigner, would demonstrate toggling in QtDesigner preview?
Ignoring QtDesigner, what would be the recommended setup to implement something like this purely in code (say, in PyQt5)?

Turns out, there is already a post discussing this - it is here:
How to make an expandable/collapsable section widget in Qt

Related

Qt: Tab Icon when QDockWidget becomes docked

Qt's QMainWindow has a ability to dock windows derived from QDockWidget. It also would put one on top on the other if few of them are stacked, producing a tab bar. Whenever a QDockWidget's state changes a signal topLevelChanged() is emmitted. At this point I would like to get access to underlying QTabWidget to set an icon for a a newly added tab. How can I do it? My patience is over trying to dig the answer out from Qt's documentation and source code. Thank you in advance.
So icon I want to be on Contents/Index tabs.
Once at least one dockwidget has been tabified, the main-window will create a QTabBar to provide the dock-tabs. Each dock-area can have its own tab-bar. These tab-bars will become children of the main-window, so you can use findChildren() or children() to get references to them.
The main difficulty will be in finding which dock-widget belongs to which tab and in which tab-bar. If the dock-widget window-titles are all unique, you can just search using the tabText(). Otherwise, you might be able to use the tabData(), which Qt sets internally to a quintptr from the dock-widget.
Once you have the correct tab, you can of course use setTabIcon() to add your icon. But note that every time a dock-widget is untabified or moved to another tab-bar, the icon will be lost.

Qt desktop application

The Qt desktop application I am required to develop has the following GUI:
The application window is split into 3 parts -
left-side window - has a stack of clickable menu items one below the other. Clicking on each item will show up the corresponding UI elements on the prominent right-side window which is much bigger.
right-side window - contains UI to display some data depending on which menu item is clicked on the left-side window. Each left-side window menu item has a different corresponding right-side window UI.
top (header) window - contains some company "brand" related graphics and also a panel to select a serial port from a list along with graphics to represent connect/disconnect status.
How do I develop this kind of UI? What Qt classes should I be using? I'm a beginner to Qt and would deeply appreciate any help. Thank you.
I'd suggest starting in Qt Designer or Qt Creator to create your UI by dragging and dropping different kinds of objects. Qt Designer is a standalone form designer where Qt Creator is full development environment that also includes the functionality of Qt Designer. Using the form designer is a lot easier, particularly when starting out, than creating widgets programmatically.
There's multiple ways to do the list of items on the left. You can use a QListWidget or a series of individual QPushButton instances, one per option. If the list of items changes, then managing the QListWidget content is going to be easier than instantiating a QPushButton for each item, but you might like the appearance of the QPushButton better. It just depends on what you want.
For the right side, look into QStackedWidget. It's specifically designed to display a stack of content where only one item is available at a time.
For the top panel, again, use the form designer to create the layout. You can store an image in a QLabel. A QComboBox might be what you want for the list, or again, you may want a QListWidget. It just depends on what appearance and user experience you're looking for. For the connect/disconnect status, you can use a QLabel and change out the graphics as the status changes.
You'll need to learn about slots and signals; those are crucial to anything Qt-related.

How to have common control in QTabWidget

I want to use a common control (QTreeView) in two different tab pages in QTabWidget.
how to do this ?
I added a tabwidget and controls in tab pages in Qt designer.
using qt creator version 2.4.1 in Win 7.
You can't have the same QTreeView in two different QTabWidget pages. When you add any widget to a layout, that layout takes ownership of the widget. Since there can only be one owner, you're stuck with one parent per widget.
But you can fake it. Give your main page a grid layout. Put a QTabBar running along the top, your QTreeView on the left (or wherever), and a QStackedLayout on the right. Connect the tab bar and the stacked layout so changing tabs in the bar changes the visible page in the stack layout.
That should be just what you're looking for - just be prepared to fight with QTabBar to get it to display like you want it to...
Alternatively, just live with having two separate tree views - they'll both be viewing the same model, after all, so the bulk of the data won't be duplicated. Saves you a fight with QTabBar, too.
Hope that helps!

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.

Need help on basic Qt structure

Hi I am a Qt beginner. I want to make something like a column of icons on the left, after click the icons different forms and results appear on the right, how can I do this? Should I choose QMainWindow or QWidget for this project?
should I choose mainwindow or widget for this
project?
If what you described are the only things present in the window, you should use a QMainWindow. If you think you will want to re-use this arrangement in the future, I'd use a QWidget. It will probably be easier to implement each set of forms as a separate QWidget (in Designer; if you're building the GUI programmatically, just add the forms to a QLayout in a QFrame).
a column of icons on the left, after click the icons different
forms and results appear on the right
For the column of icons, you should look at QListWidget. It provides a vertical list of QListWidgetItems, and the items can contain icons, and nothing else. Your main window can then connect to the list widget's currentItemChanged signal (or itemChanged or something else; there are several choices), and modify the forms in the right-hand side of the window appropriately.

Resources