How to collapse Gtkmm notebook tabs? - c++

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.

Related

Qt splitter auto resizing

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.

C++ Win32 how to remove tab borders WC_TABCONTROL

Hi I am trying to convert an existing WC_TABCONTROL window with TCS_OWNERDRAWFIXED so that I have full control of its appearance.
But it seems all I can draw is the tab headers and even there I do not have much control on how the borders are drawn around tab page as well as tab headers.
Can someone point me to some material that explain how to custom draw, tab items and tab pages. I need to have control on how both the background and borders are drawn.

QTableWidget show scroll bar

I would like the horizontal scroll bar to appear whenever there is text eliding. Such that the user won't have to resize the whole GUI. How would I do this?
This is what I have coded:
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
ui->tableWidget->resizeColumnsToContents();
I also tried enabling scrollbar to appear always, but scrolling to the very right doesn't do anything.
If I set textElideMode to ElideNone , the text from the 2nd column is partially hidden and no scrollbar appears.
QHeaderView::Stretch will stretch the column width to the available space. Use QHeaderView::ResizeToContents to make the column wide enough to display the content, resulting in a horizontal scroll bar if necessary.
This will have a couple of side effects of which I'm not sure you want them.
There will probably be no more ellipsis in the elided text.
If all of the values in your Hash column are very small, then that column will be very thin, so there might be 'empty' space next to that column.

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?

Qt splitter layout resize behaviour using Qt Designer

I have an issue with size in my view made in Qt with drag and drop.
Let me start with an image to help me explain
This is the mainwindow for my form.
What happens is:
We have 4 tab widgets. the left tab widget has a horizontal splitter to the 2 mid widgets.
The 2 mid widgets have a vertical splitter, and a horizontal splitter on the left and right side.
The right widget has a vertical splitter on its left hand.
So all views are connected using splitters.
Lastly the mainform sticks every thing together in a resizable way using horizontal layout.
The problem is, the width of the leftmost and rightmost widgets are fixed (in designer).
I want them to be smaller in width. Something similar to:
You can see the widgets are resized. I was able to do this running the application, and manually adjusting the splitters. Is there a way in QtDesigner to do this? I tried playing with policies. I didn't really get any further however. Does this indicate a lack of knowledge of my part about policies? Perhaps layouts in general?
What options should I use to achieve the desired layout using QtDesigner. I want to avoid using code.
Hope I will be able to solve this soon. It must be overlooking something simple..
You can play with the "Horizontal Stretch" and "Vertical Stretch" properties to change the position of the split.
For example with both the vertical stretch of the top central QTabWidget and the horizontal stretch of the central QSplitter at 1 and all the other values kept at 0, you'll get the result you want.
When you have multiple non-zero stretch values, the result of the ratio (e.g.: vertical strech at 2 and 1 for the 2 central QTabWidgets => 2/3 and 1/3) is not visible in the designer but seems to be working when you run the application.
PS: You can also achieve the same result with tabbified QDockWidgets but the dock tabbification is not possible through the designer only.
I set start position that:
QList<int> list= ui->splitter->sizes();
list.replace(0,this->height()/0.3);
list.replace(1,this->height()/0.7);
ui->splitter->setSizes(list);
and remember to minimum size child widget