Qt splitter auto resizing - c++

I have a 4 way splitter in qt, i want to be able to expand the splitter when a user moves one of the tabs instead of collapsing the other tabs to make room.
This is the default state of the splitter when the program launches:
This is the state of the splitter after I try to expand the left most tab of the splitter.
See how in the second picture the splitter has just smushed the three tabs on the right together to make room for the tab I expanded? Instead of this happening i would like the entire splitter to grow to preserve the size of the 3 tabs on the right and to accommodate the expanding left tab.
One last thing, this splitter is nested inside a scrollarea to accommodate the expanding splitter widget.
Does anyone know how I would go about accomplishing this?
One idea that I had was to keep track of the sizes of the individual tabs before and after the user resizes a splitter and then adjust the size of the entire splitter to reflect the increase or decrease in the adjusted tab and reset the other tabs to what they were prior to the change. However I am not sure how to get the sizes of all of the tabs before and after a resize.

Related

gtkmm: stack together elements in the container widget (Box)

I want to create some kind of toolbar, consisting of buttons. I used ButtonBox, and put inside some toggle buttons, color button and one regular button.
I want to accomplish two things:
Make buttons stick together despite window width, without margin between them.
Have rightmost button on the right of the window, and other buttons on the left.
If I didn't wanted second thing, I could just use set_valign so that toolbar would shrink to the right.
I tried adding empty Gtk::Box after color button and allowing it to expand, and this keeps rightmost button on the right, but it still leaves margins between buttons, no matter what parameters for pack_start and pack_end I try - there is two optional boolean parameters, but neither of them seem to do anything.
Here is how it looks normally:
Here is how it looks with empty box:
So what should I do to remove margin between buttons, and is there a better way to keep some buttons on the right, and some on the left?
ButtonBox will always have space between buttons. If you want the buttons without space between, use a regular Box.
Otherwise you did the right thing. Use a Box to move the right button to the edge. Sometimes you can achieve the same affect by using pack_start and pack_end to different buttons, all within the same Box.

How to fit all the widgets together using grid Tkinter

I'm trying to fit all widget, I have tree frames:
First frame:
Have a label (that need to have some name with a big letter size)
A custom combobox to change the value of the label if nedded
A button to make the selection of the combobox
Second frame:
Have a treeview with some information that when I make a clic in one row another treeview appears in the 3rd frame. This treeview have occupy all the frame
Third frame:
Have three columns:
The first one have two rows:
Fist row two buttons add and remove, that have occupy all the row.
Second row a treeview that have occupy all it space. This treeview appears when click a row in the first treeview, how can I show the empty treeview and fill in when click the row. The function is OnDoubleClick
The second column:
Have two buttons that have to be in the center of the rows.
The third column:
Same as the first but with other treeview.
Here is an image of what i want to achive:
I'm not going to rewrite your whole program because that's a lot of code, but I'll explain the way I would approach the problem. Tkinter layout is really simple if you are methodical and organized, and try to solve only one problem at a time.
Main layout
First, you seem to have three main sections: a toolbar across the top, a middle section with a treeview, and a bottom section with a whole bunch of stuff. So, first thing I would do is create three frames, one for each section. Then, I would use pack like this:
toolbar.pack(side="top", fill="x")
main.pack(side="top", fill="both", expand=True)
bottom.pack(side="top", fill="both", expand=False)
I don't know if that third section should expand or not. It's not clear what sort of behavior you expect when the user resizes the window.
Toolbar layout
This one is very straight-forward. It's three widgets spread equally. You can use pack or grid, either will work just fine.
Main layout
This just has a treeview, or maybe a treeview with scrollbars? Again, pack or grid works just fine with such a simple layout.
Bottom
This one appears to be made up of three sections: a left section, a middle section, and a right section. Like with the main layout, I would start by creating three frames, all as children of the "bottom" frame created earlier. Then, I would again use pack since it's a simple horizontal layout:
left.pack(side="left", fill="both", expand=True)
middle.pack(side="left", fill="both", expand=False)
right.pack(side="left", fill="both", expand=True)
By setting expand=True to the left and right sides, if the window grows or shrinks, these will grow or shrink too while the middle section stays its natural size.
Bottom-left and Bottom-right
Both of these look identical. It looks like the easiest thing to do would be to create the widgets (ie: no more frames), and then use grid to lay them out. Though, if by "buttons" you mean you could have several, you could create a frame for the buttons so that you can more easily pack all the buttons from left to right.
Bottom-center
You can create buttons that are a child of this frame, and use either grid or pack.

How to collapse Gtkmm notebook tabs?

So I am making a Gtkmm application using a Gtk::notebook and during run-time I'm adding new tabs to the notebook. But when I add more tabs than there is space on my screen it just keeps going moving out of the screen.
Now I know most Gtk widgets have a lot of properties that can be configured, so I'am wondering is there such a property for notebook that automatically collapses tabs or scales them in some way to make it fit inside the widget/screen.
If not it would be great if you could give me some pointers to how to implement this functionality myself.
set_scrollable() is your best bet. It will add scrolling arrows on the sides of the tab labels at the top when there isn't enough room to show them all.
Note that GtkNotebook will always ask for enough space to show the contents of all tabs, not just the one that's currently visible. If one of your tab pages is really big (say, contains a 10x10 grid of 100x100 buttons), you won't be able to resize the GtkNotebook smaller than that tab page (in that case, 1000x1000 + the height of the label area), even if the current tab page is just an empty container. All set_scrollable() will do is let you resize smaller than the width needed to show all tab labels at the top.
Put this in your .xml GUI file in the GtkNotebook object:
<property name="scrollable">True</property>
This causes the tabs that go out of screen to be horizontal scrollable by adding arrows beside the last tab at the right and the most left tab at the left.

How can I overlap qwidgets while using the grid layout and positioning overlapping widgets a particular distance from the window border?

I am programming a game and I have a tab widget which takes up the majority of the window. I want to use the extra space in the tab bar for buttons. I have the tab widget in a grid layout. To accomplish this, I use the code below in order to remove and add back the button widgets to the desired areas (the solution to someone else's question).
ui->centralLayout->removeWidget(ui->exitButton);
ui->centralLayout->removeWidget(ui->ResizeButton);
ui->centralLayout->addWidget(ui->ResizeButton,0,4, Qt::AlignTop|Qt::AlignRight);
ui->centralLayout->addWidget(ui->exitButton,0,4, Qt::AlignTop|Qt::AlignRight);
This does not work for me; however, because I would like the second widget-- the resize button-- to be just to the left of the exit button. What is occurring is that it instead overlaps the exit button. I simply need to move it 21 pixels to the left and have no idea how!
I tried putting both buttons in a frame and then removing and adding the frame the way I did the buttons. Unfortunately the same functions I used do not exist for the qt frame object.
Here are some pictures of my window.
https://docs.google.com/document/d/17w5USWQcCtb6OdcRShdcYcRjXTcdVpmdrG5TWLX71y8/edit?usp=sharing
you are using void QGridLayout::addWidget(QWidget * widget, int row, int column, Qt::Alignment alignment = 0) overload.
2-nd and 3-rd parameters are row and column of a grid. And you put 2 widgets in the same cell so they are overlaping each other.
I solved my problem. Earlier when I was trying to add them to a frame and reposition it I could not but using a widget as the container for my buttons let me place them the way I was earlier attempting to individually place the buttons.

ScrollArea and TabWidget resizing

I am having trouble with my app. I am not able to configure wigets to behave acording to my needs, I would appreciate help.
This is “sketch” of my real app
http://s13.postimage.org/ibzzdh3p3/tab_Widget.png
So the main widget of MainWindow is scrollArea.
ScrollArea has vertical layout and contains 3 items.
1. Is big button, which represents constant sized area in my real app
2. Is spacer
3. TabWidget, has layouts on both tabs.
Now my problem. I am putting dynamically content into those tabs and I expect that if tab content cannot fit the tab than it will expand TabWidget in the scroll area.
Now it is filling space right when it fits the place, nice spacing and so. But if I fill it with lets say more lines(height 600px), than I can see the lines dissapearing somewhere down the tab and if I expand whole window TabWidget gets more space and more of my hiden widgets gets revealed.
Any ideas how can I force the content of the tabwidget to expand it rather then hide under?