Qt Forum

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

    QStackedLayout added to mainwindow layout automatically, Why?

    General and Desktop
    2
    3
    890
    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.
    • B
      bigrockcrasher last edited by

      I am currently writing a program using Qt's GUI. in the contructor of the main window I declare a QStackedLayout without any options in the constructors arugments. then I set the layout with the newly declared layout. for some reason when I run the code it says
      "QWidget::setLayout: Attempting to set QLayout "" on REDcap_GUI "", which already has a layout"
      If I were to remove the line to set the layout, It works just fine. Does Qt know to automatically add it to the layout? All tutorials have a line to add a stackedlayout to the to the main window.

      1 Reply Last reply Reply Quote 0
      • B
        bigrockcrasher last edited by

        Ok problem solved. I was using QMainWindow as my windows manager. Apprently you are suppose to use setCentralWidget. Doing this resolved many other issues too.

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi and welcome to devnet,

          Indeed, QMainWindow already has a layout which handles its complex content e.g. toolbars, status bar, dock widgets etc.

          You can also consider QStackedWidget for your central widget, it will avoid to have a placeholder widget to set your QStackedLayout on.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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