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. QLayout: Attempting to add QLayout "" to QMainWindow "", which already has a layout

QLayout: Attempting to add QLayout "" to QMainWindow "", which already has a layout

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 2.8k 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.
  • kahlenbergK Offline
    kahlenbergK Offline
    kahlenberg
    wrote on last edited by
    #1

    Hello,
    I have problems regarding to layout of QMainWindow. I know QMainWindow has already layout, but if I try to create QHBoxLayout, I get this warning:

    QLayout: Attempting to add QLayout "" to QMainWindow "", which already has a layout

    MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) 
    {
        QStackedWidget *stackedWidget = new QStackedWidget(this);
        QWidget *widget = new QWidget();
        QMenu * fileMenu = menuBar()->addMenu(tr("&File"));
        QHBoxLayout *layout = new QHBoxLayout(this);  
        // QTreeWidget *tree   = new QTreeWidget(this);
    }
    
    

    mainwindow.h

    class MainWindow : public QMainWindow
    {
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
    
    };
    

    pro file:

    QT       += core gui xml network testlib
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = SCADA
    TEMPLATE = app
    
    
    SOURCES +=  main.cpp\
                mainwindow.cpp
    
    HEADERS  += mainwindow.h 
    
    
    1 Reply Last reply
    0
    • kahlenbergK Offline
      kahlenbergK Offline
      kahlenberg
      wrote on last edited by
      #2

      Sorry,
      I solved the Problem.

      QHBoxLayout *layout = new QHBoxLayout(widget);  // not this :)
      
      1 Reply Last reply
      1

      • Login

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