Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    what's the difference between QStackedLayout and QStackedWidget?

    General and Desktop
    3
    6
    2017
    Loading More Posts
    • 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
      opengpu2 last edited by

      what's the difference between QStackedLayout and QStackedWidget?

      1 Reply Last reply Reply Quote 0
      • G
        GrahamL last edited by

        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 Reply Quote 1
        • sierdzio
          sierdzio Moderators last edited by

          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 Reply Quote 1
          • O
            opengpu2 last edited by

            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 Reply Quote 0
            • sierdzio
              sierdzio Moderators last edited by

              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 Reply Quote 0
              • G
                GrahamL last edited by

                QStackedWidget has a QStackedLayout member

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post