Alternative to StackLayout for tabbed view
-
I was looking to simplify the layout logic in my application by removing the use of the
Layout
types. I have largely succeeded or can at least see where to go. The only problematic instance is a use ofStackLayout
for a "tab view" area of my application, for which I currently useTabBar
+StackLayout
.The documentation for
TabBar
suggests usingStackLayout
orSwipeView
, 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?
-
@qwasder85 I feel like I have a bit of a mish mash of approaches at the moment, with anchors in one place and
Layouts
in another and some complications at the interface between them.Perhaps incorrectly, I also have the impression that
Layouts
are more associated with Quick Controls 1 - for example, the QC1SplitView
usesLayouts
whereas 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.
-
@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
SplitView
beingLayout
-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
Layouts
when 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
StackLayout
remains the best way to implement a tabbed view then I am happy to stick with it. Thank you for your advice.