Alternative to StackLayout for tabbed view
-
I was looking to simplify the layout logic in my application by removing the use of the
Layouttypes. I have largely succeeded or can at least see where to go. The only problematic instance is a use ofStackLayoutfor a "tab view" area of my application, for which I currently useTabBar+StackLayout.The documentation for
TabBarsuggests usingStackLayoutorSwipeView, but the latter sounds like it might be bringing more behaviour with it than is strictly needed.Are there any alternatives that I am missing that people would tend to favour these days?
-
I was looking to simplify the layout logic in my application by removing the use of the
Layouttypes. I have largely succeeded or can at least see where to go. The only problematic instance is a use ofStackLayoutfor a "tab view" area of my application, for which I currently useTabBar+StackLayout.The documentation for
TabBarsuggests usingStackLayoutorSwipeView, but the latter sounds like it might be bringing more behaviour with it than is strictly needed.Are there any alternatives that I am missing that people would tend to favour these days?
-
@Bob64 QStackedWidget?
Why do you want to get rid of layouts? They're one of the good parts of Qt. :D@qwasder85 I feel like I have a bit of a mish mash of approaches at the moment, with anchors in one place and
Layoutsin another and some complications at the interface between them.Perhaps incorrectly, I also have the impression that
Layoutsare more associated with Quick Controls 1 - for example, the QC1SplitViewusesLayoutswhereas the replacement QC2 version does not. It seems that they are not generally the favoured approach these days.Edit: sorry just noticed : you thought I was talking about Qt Widgets - no I am talking about QML. It's been a few years since I used widgets, but yes layouts are pretty fundamental there IIRC.
-
@qwasder85 I feel like I have a bit of a mish mash of approaches at the moment, with anchors in one place and
Layoutsin another and some complications at the interface between them.Perhaps incorrectly, I also have the impression that
Layoutsare more associated with Quick Controls 1 - for example, the QC1SplitViewusesLayoutswhereas the replacement QC2 version does not. It seems that they are not generally the favoured approach these days.Edit: sorry just noticed : you thought I was talking about Qt Widgets - no I am talking about QML. It's been a few years since I used widgets, but yes layouts are pretty fundamental there IIRC.
-
@qwasder85 no problem :)
-
@qwasder85 no problem :)
@Bob64 Why are you under the impression that Layouts is not favored?
QQC2 don't use Layouts internally because they generally position their visual item in C++ but they are perfectly fine as a container element in user code.
There's no need for an alternative for StackLayout for a tabbed view.
What's bad in StackLayout that you'd want to be changed?Even the official documentation of TabBar uses StackLayout.
-
@Bob64 Why are you under the impression that Layouts is not favored?
QQC2 don't use Layouts internally because they generally position their visual item in C++ but they are perfectly fine as a container element in user code.
There's no need for an alternative for StackLayout for a tabbed view.
What's bad in StackLayout that you'd want to be changed?Even the official documentation of TabBar uses StackLayout.
@GrecKo well, I did already acknowledge that I could be wrong! It was just an impression from things like I mentioned such as the old
SplitViewbeingLayout-based and the new one choosing not to do this.I guess it is also the case that in some places I originally got various things working with
Layoutswhen I had very little idea what I was doing. Not because it was necessarily the best way to do it but because I tried a few things and I happened to get that one working first. I have had a few experiences recently where I have looked at old code and ended up changing away fromLayouts.If
StackLayoutremains the best way to implement a tabbed view then I am happy to stick with it. Thank you for your advice.