Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Alternative to StackLayout for tabbed view

Alternative to StackLayout for tabbed view

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 3 Posters 771 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bob64
    wrote on last edited by
    #1

    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 of StackLayout for a "tab view" area of my application, for which I currently use TabBar + StackLayout.

    The documentation for TabBar suggests using StackLayout or SwipeView, 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?

    qwasder85Q 1 Reply Last reply
    0
    • B Bob64

      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 of StackLayout for a "tab view" area of my application, for which I currently use TabBar + StackLayout.

      The documentation for TabBar suggests using StackLayout or SwipeView, 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?

      qwasder85Q Offline
      qwasder85Q Offline
      qwasder85
      wrote on last edited by qwasder85
      #2

      @Bob64 QStackedWidget?
      Why do you want to get rid of layouts? They're one of the good parts of Qt. :D

      B 1 Reply Last reply
      0
      • qwasder85Q qwasder85

        @Bob64 QStackedWidget?
        Why do you want to get rid of layouts? They're one of the good parts of Qt. :D

        B Offline
        B Offline
        Bob64
        wrote on last edited by Bob64
        #3

        @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 QC1 SplitView uses Layouts 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.

        qwasder85Q 1 Reply Last reply
        0
        • B Bob64

          @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 QC1 SplitView uses Layouts 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.

          qwasder85Q Offline
          qwasder85Q Offline
          qwasder85
          wrote on last edited by
          #4

          @Bob64 Sorry, I'm stupid. I forgot that his board is also about QtQuick. My bad.

          B 1 Reply Last reply
          0
          • qwasder85Q qwasder85

            @Bob64 Sorry, I'm stupid. I forgot that his board is also about QtQuick. My bad.

            B Offline
            B Offline
            Bob64
            wrote on last edited by
            #5

            @qwasder85 no problem :)

            GrecKoG 1 Reply Last reply
            0
            • B Bob64

              @qwasder85 no problem :)

              GrecKoG Offline
              GrecKoG Offline
              GrecKo
              Qt Champions 2018
              wrote on last edited by
              #6

              @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.

              B 1 Reply Last reply
              0
              • GrecKoG GrecKo

                @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.

                B Offline
                B Offline
                Bob64
                wrote on last edited by Bob64
                #7

                @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 being Layout-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 from Layouts.

                If StackLayout remains the best way to implement a tabbed view then I am happy to stick with it. Thank you for your advice.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved