Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. what's the difference between QStackedLayout and QStackedWidget?
Forum Updated to NodeBB v4.3 + New Features

what's the difference between QStackedLayout and QStackedWidget?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.6k Views 3 Watching
  • 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.
  • O Offline
    O Offline
    opengpu2
    wrote on 1 Apr 2015, 08:07 last edited by
    #1

    what's the difference between QStackedLayout and QStackedWidget?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      GrahamL
      wrote on 1 Apr 2015, 08:30 last edited by
      #2

      From the documentation
      QStackedWidget can be used to create a user interface similar to the one provided by QTabWidget. It is a convenience layout widget built on top of the QStackedLayout class.
      QStackedLayout
      QStackedWidget

      1 Reply Last reply
      1
      • S Offline
        S Offline
        sierdzio
        Moderators
        wrote on 1 Apr 2015, 08:31 last edited by
        #3

        Their APIs are different, although they share a lot of similarities. And one is a widget, while the other one is a layout.

        (Z(:^

        1 Reply Last reply
        1
        • O Offline
          O Offline
          opengpu2
          wrote on 1 Apr 2015, 09:05 last edited by
          #4

          for me , right now, i just want to use QStackedXXX to make 2 or more different widgets at the same place with the same size, to be visible just 1 widget at 1 time.
          will QStackedLayout more efficient?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sierdzio
            Moderators
            wrote on 1 Apr 2015, 11:16 last edited by
            #5

            It'd rather recommend to use the one that is more convenient for your GUI architecture. If you already have a layout in your GUI, then it is easier to instert a widget into it - in such case I would vote for using QStackedWidget.

            As for ""efficiency" depends on what you are interested in. CPU load? RAM usage? Number of CPU cache hits? You'll have to benchmark both solutions to get definite answers. I do not know whether any of the two is "better". The documentation claims QStackedWidget is done on top of QStackedLayout, but it is not inheritance (those classes are not related).

            (Z(:^

            1 Reply Last reply
            0
            • G Offline
              G Offline
              GrahamL
              wrote on 1 Apr 2015, 11:22 last edited by
              #6

              QStackedWidget has a QStackedLayout member

              1 Reply Last reply
              0

              2/6

              1 Apr 2015, 08:30

              topic:navigator.unread, 4
              • Login

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