Qt Tab widget that wraps its menu bar - qt

When the menu of a QTabWidget grows beyond its width, the default behaviour is to turn the tab menu into a horizontaly scrollable list. What I'd prefer is to wrap the menu round so you now have two rows of tabs. This style is used on some Windows dialogs. I can't find any way to do this though.
Is anyone aware of a trick or option to allow this kind of layout?

This option is currently not available for QTabWidget. Perhaps you could simulate this behavior using a few QTabBars?
There is an outstanding request for this on Qt's bug tracker but no progress on it yet. Perhaps somebody knows of another component/solution.

Flow layout does what you need, but then you will have to also make your own "tab widget" http://doc.trolltech.com/4.7/layouts-flowlayout.html

Related

How to move a QPushButton inside gridLayout?

I have just tried a simple thing, in designer I created one push button, inside grid layout. The problem is geometry option got disabled in Property box, and I am not able to change the cordinates. In this situation how should I move the push button from its original place if required?
Can somebody help me to achieve this??
You can't move or resize a widget inside a layout because its position and its size are managed by the layout. If you want to manage its geometry yourself, do not use a layout.
Qt layouts are designed to help you make scalable user interfaces. For this, moving or resizing the button is usually done by the layout using sizeHint() and sizePolicy().
I would suggest reading up on how to use layouts and the use of spacers, as this will impact the location and size of your button.
Well I found a solution to that
Break the Layout, arrange the widgets and then set the layout

qml: achieve a chrome-like menu

I would like to achieve with QML a menu with a single menu item, like chrome does it. It has this button with those three horizontal bars and when you click it you get a single menu. Recent versions of firefox also follow the same principle. It allows not to waste too much horizontal space in the GUI of the application, unline usual menus which take up the whole width of the window.
I did not manage to reproduce exactly this GUI with QML. From what I saw you can either use a QML ApplicationWindow, and then a MenuBar, but then it takes the whole width of the window... Or have a toggle button to trigger the menu, then use a standalone Menu and its popup() method, but then it pops-up directly under the cursor, not exactly under the button to open the menu, which doesn't look good. That's really more abusing the mechanism for a context menu.
I could make a fake menu which would be a custom widget in my window but then it could not expand beyond my application window. Such a behaviour is almost required because I'll put this button on the far right of the window, as chrome does it.
Is it possible to achieve exactly that behaviour in pure QML (no C++)?
What I did for now is the last option that I mentioned: fake menu in the window. It's drawing using the canvas which enables me to make it a little pointy arrow from the menu to the menu toggle button, as done also by firefox.
The minus as I said is that the menu cannot go out of the window, plus everything is very manual (mouseover effect for menu items...), so I'm still interested in other solutions.
EDIT: ok after some time I realized a big plus of my approach: I can put custom widgets, not only labels in the menu. So I think it's absolutely the right approach now.

Qt5: how to resize two UI lists against each other

I would like to be able to resize two QListWidget that sit in a QVBoxLayout, by grabbing the edge in the middle of the two and sliding it up or down. One would shrink, the other would get bigger.
Here is a screenshot of a sample app:
I would like to be able to grab the bar between the two lists and resize them.
This is what it looks like in the Qt layout editor:
I'm not sure if the vertical layout is the good choice, here, there may be another vertical layout that provide this functionality maybe?
Is it even possible with Qt?
You need to use QSplitter. It's available in the form designer.
To add to Riateche's correct answer, you can also use qt-designer to add specify the type of layout (QSplitter) by first selecting the widgets and then right-click to layout->horizontal splitter etc.
Here's a simple tutorial I ran by a few years ago: http://www.youtube.com/watch?v=E7Ud6FonsR4

Force MenuBar to always open downward

I have a MenuBar which opens downwards except when there isn't enough room to open it. For example, it may have 10 items but there's only enough room to display 4-5. Flex then tries to display the menu above the bar, which is completely off the screen. Is there some property or style I'm overlooking to always force it to open downward?
EDIT: Thought I'd give some clarification as to how I plan to circumvent the issue. If I can always force the menubar to be orientated downwards, I can make it into a scrollable menubar displaying only a few items at worst.
I do not have a direct answer. However, the best resource I have ever seen on the menuBar component is here.
http://adobestudionews.net/devnet/flash/articles/creating_as3_components_pt2.html
My guess is it is buried in the renderers.

Qt: How to handle forms?

I'm creating an application in Qt (Nokia SDK) which should hold a login screen, main menu screen, etc....
But what is the best way to jump back and forward on these screens?
I have recently looked at Stacked Widget, and it seems like that could solve my case, but it has some kind of margin on itself, that makes it look weird. (Makes the widget not fill the entire screen)
Any suggestions?
Thanks in advance!
if you are using a layout, select it and in properties, set margin values to 0
QStackedWidget doesn't have any margins. You should check if you are using layouts with margins. Usually you will have layout for each page of stacked widget.

Resources