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. Trying to replace widget
Qt 6.11 is out! See what's new in the release blog

Trying to replace widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 979 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.
  • A Offline
    A Offline
    Alex Povolotsky
    wrote on last edited by
    #1

    Hello

    I've designed a main window in Designer (frame with button on top, frame with button on bottom, frame with placeholder between them).
    Now I want to replace central frame with a different widget (a widget with a vertical-centered progress bar, than, after setup, with a QCustomPlot).
    However, centralWidget->layout()->replaceWidget removes a widget without adding anything; attempt to add a widget into central widget (ui->areaHolder->layout()->addWidget(wb);) adds it somewhere under existing spacer.

    How do I replace a widget in Designer-generated UI?

    jsulmJ 1 Reply Last reply
    0
    • A Alex Povolotsky

      Hello

      I've designed a main window in Designer (frame with button on top, frame with button on bottom, frame with placeholder between them).
      Now I want to replace central frame with a different widget (a widget with a vertical-centered progress bar, than, after setup, with a QCustomPlot).
      However, centralWidget->layout()->replaceWidget removes a widget without adding anything; attempt to add a widget into central widget (ui->areaHolder->layout()->addWidget(wb);) adds it somewhere under existing spacer.

      How do I replace a widget in Designer-generated UI?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Alex-Povolotsky Why do you need to replace the central widget? You can simply use the existing one. If you need to switch between different widgets you should use QTabWidget.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        or QStackedWidget

        jsulmJ 1 Reply Last reply
        2
        • C ChrisW67

          or QStackedWidget

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @ChrisW67 Oh, yes this is what I actually wanted to write :-)

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Alex Povolotsky
            wrote on last edited by
            #5

            I did not quite get what I've done, but it works now.

            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