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. QStackedLayout added to mainwindow layout automatically, Why?

QStackedLayout added to mainwindow layout automatically, Why?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k 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
    bigrockcrasher
    wrote on last edited by
    #1

    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
    0
    • B Offline
      B Offline
      bigrockcrasher
      wrote on last edited by
      #2

      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
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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
        0

        • Login

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