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?
Forum Updated to NodeBB v4.3 + New Features

QStackedLayout added to mainwindow layout automatically, Why?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k Views 1 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.
  • B Offline
    B Offline
    bigrockcrasher
    wrote on 26 Dec 2014, 18:23 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 26 Dec 2014, 21:23 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
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 26 Dec 2014, 22:19 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

        1/3

        26 Dec 2014, 18:23

        • Login

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