I have a group box or the like containing a combobox and some more widgets that shall not all be visible at the same time. Depending on the selection I want at the same place to be displayed a button or a line edit or a (second) combobox. So if combobox entry one is selected it shows the button, if entry two is selected it shows the line edit, if entry three is selected it shows the second combobox, while not showing the other two.
I know that I can do it all dynamically but this results in a lot of code lines. I want to use QT Designer and a grid layout and I can't see how to put two widgets at the same place and then make only one visible programmatically.
I hope I could explain properly.
I played with Qt Designer but could not place two widgets over one another in a grid layout.
Thanks for any help.
Thank you G.M.
Yes, I was looking for QStackedWidget. I wasn't aware of this at all. I tried it and it works easily out of the box.
Related
this is the situation:
We have a series of tabs, which have card-like elements inside. The designer choose to push a "change display" feature which hides part of the content of the cards (image, description) to increase the displayed number per time.
The problem:
The designer choose to put this change display button, in the tabs section. Like (Tab - Tab - Button).
After a couple hours of research, I couldn't find a way to place a button inside the <b-tabs> component (which has X number of <b-tab>). I had to use float, position absolute and use coordinates to place the button, but obviously this is not a desirable solution.
Is there a better approach to this problem? Or it's possible to place the button inside the component itself?
Thanks.
Edit:
#Anatoly gave the answer !
Thanks.
Try to use tabs without a content, described here
I am new to Qt Designer so this question may be stupid but I'm really stucked.
I'm creating an app using Qt Designer and PyQt5. My app contains a few screens and I want to switch between them by clicking the button.
The first screen consists of a button (button_1) and a label (label_1) placed in a vertical layout. The second screen also consist of a button (button_2) and a label (label_2), but these are different widgets with different size and content. And I want to place button_2 and label_2 in a horizontal layout.
Previously I didn't use layouts. I just created one .ui file and put button_2 and label_2 above button_1 and label_1. They were overlapping but it didn't affect the performance because I made the button_2 and label_2 invisible when button_1 and label_1 are shown and vice versa. But now I need to make the window resizable, and I need to put the widgets in a layout.
The first thought was to create two separate .ui files and set them using loadUi command when it comes to switching between screens. But I need to use just one .ui file. Is this possible? How can I create two independent layouts? Or maybe there is another way to solve my proble. Any help is very much appreciated.
I think that in this case your best option is to use a QStackedWidget as a container for your labels and buttons. To create a stacked widget in Qt Designer you can drag a Stacked Widget from the container group on the left to the parent widget. This will create a stack with two pages. Each page can then be set up independently. Whatever layout you and widgets you add to a particular page will only be visible when that page is shown. You can add additional pages if you like by right-clicking on the stacked widget and selecting Insert Page from the context menu.
To navigate between the pages in Qt Designer you can choose the correct widget in the tree in the Object Inspector, use the two black arrows in the top-right corner of the stacked widget, or use the context menu of the stacked widget. To navigate between the pages in your python script you would need to use QStackedWidget.setCurrentIndex().
Before i embark on developing a custom control i wonder if somebody would know of a QT control consisting of an edit box (for a number) with more than one spinner next to it. One spinner would be used to increment/decrement the number by 10's, the other by 1's. Ideally, one could allow even three spinners (for the 100's).
There is no standalone spinner but i'm thinking maybe putting several small scrollbar controls next to each other would do.
I highly doubt that there is such a control.
Note however that a default QSpinBox supports incrementing/decrementing in steps of 10 by pressing the Page Up or Page Down keys on your keyboard.
Thanks for the tip!
I ended up creating a horizontal layout with 0 spacing, then placing three QDoubleSpinBox instances in it. On the second and third i set the max width to 15 to just show the spinners. Visually it looked great: an edit box with three spinners.
I then connected the value changed signal from the first to the second and third and the value changed from the second and third to the first. So then clicking on any of the spinners changed the value on the first correctly. Finally, i adjusted the stepsize on the spinners as needed.
It was a lot easier than what i thought it would be.
When I use treetable in Vaadin, it is working fine drag and drop the whole row when click the left and right blank ereas. but that is not user friendly, I wanna create a draggable layout inside the row, let's say the 1st component of the each row, that when clicking it, the whole row is selected and can be draged and dropped to reorder.
The thing is I can create a vertical layout with wrapper doing that, but drag mode is only for its component or the wrapper itself, and when doing the drag action, it doesn't actually showing the whole row is moving, which may confuse the clients. What can I do to make it looking like I am dragging the whole row, similar with the one you drag the blank area of each row? Thanks.
I'm afraid there currently is no way for adding a wrapper that would extend the entire row instead of just one cell. To do this you'd need to extend the client-side implementation of Table (VScrollTable) and this is not something I would recommend as it is quite complex.
I do think that what you describe should be possible in core Vaadin (without using drag & drop wrappers), so could you please file a ticket at dev.vaadin.com? And please attach a small application showing the problem to make it easier for us to see the problem and fix it.
Anyways, in order for you to get it working today I'd suggest that you change your UI design a bit and for example borrow drag handles from iOS. By this I mean that you could add an icon that suggests "draggable" as a background-image in the first cell (or in the row header cell of each row) that encourages the user to grab the row there, where it is "empty" and dragging works. This way the user might not be too confused if dragging only works reliably in some parts of the rows.
HI..
i am new to QT,i want to know how to customize the listview in QT i.e i want to add multiple icon in single row.. etc.. i tried lot i am not getting how to do that..
i tried with Qlistwidget, in tat i can only insert single row with one image.. i am not able to place multiple icon with desired locations..
please assist me, which control is good listview or listwidget.
and how to customize the same according to my view
if you have any sample examples. please provide me the link.
Thanks
You can implement a delegate to customize the rendering of the items in your view.
From the model/view programming docs: delegates are responsible for rendering individual items in the views.
See the pixelator sample for example usage.
Take a look at QTableView or QTableWidget. You can insert the icons in the first two columns and the text in the third column. Or any other way you like it.
I guess you can use some delegates.
Have a look at http://qt.nokia.com/doc/4.6/model-view-delegate.html
Hope it helps !