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. Help with this message

Help with this message

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

    Hi i did one project in qt but show me this message:
    QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout

    How i can solve this issue. Thanks in advance.

    jsulmJ 1 Reply Last reply
    0
    • RIVOPICOR RIVOPICO

      Hi i did one project in qt but show me this message:
      QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout

      How i can solve this issue. Thanks in advance.

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

      @RIVOPICO Don't add a layout because there is already one (as the message says). Use the existing layout via http://doc.qt.io/qt-5.7/qwidget.html#layout
      If you really want to set your own layout then remove the old one, please read this to find out how, it is explained there: http://doc.qt.io/qt-5.7/qwidget.html#setLayout

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

      1 Reply Last reply
      1
      • RIVOPICOR Offline
        RIVOPICOR Offline
        RIVOPICO
        wrote on last edited by
        #3

        i think the part the code is this:
        void MainWindow::generarVentanaChat()
        {
        /** Crea una ventana de chat **/
        this->chat = new QWidget(0,Qt::CustomizeWindowHint);
        this->capa = new QVBoxLayout(chat);
        this->capaHorizontal = new QHBoxLayout(chat);
        this->botonChatEnviar = new QPushButton("Enviar",chat);
        this->enviarChatTexto = new QLineEdit(chat);
        salidaChatTexto = new QPlainTextEdit(chat);
        capa->addWidget(salidaChatTexto);
        capaHorizontal->addWidget(enviarChatTexto);
        capaHorizontal->addWidget(botonChatEnviar);
        capa->addLayout(capaHorizontal);
        }
        You refer to this?

        SGaistS 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          When passing a widget as parent of a layout, the layout is applied to the widget. Since you are declaring several layouts that way you are getting that error.

          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
          1
          • RIVOPICOR Offline
            RIVOPICOR Offline
            RIVOPICO
            wrote on last edited by
            #5

            And my code will be one example of this? it's only for knowing thx

            1 Reply Last reply
            0
            • Venkatesh VV Offline
              Venkatesh VV Offline
              Venkatesh V
              wrote on last edited by
              #6

              Hai...
              I think you are using QmainWindow, that already have layout.... so instead of using QMainWindow you just use QWidget.... or else if you wanted to use QmainWindow than you do one thing first you take one Qwidget object and set that widget as centralwidget and after that you can set layout to widget Object...

              for example:

              Qwidget *w=new Qwidget;
              setCentralWidget(w);
              QHboxLayout *lyt= new QHboxLayout;
              w->setLayout(lyt);
              //then add your all the widget to layout this will work
              lyt->addwidget(widget1)
              lyt->addwidget(widget2)
              lyt->addwidget(widget3)

              RIVOPICOR 1 Reply Last reply
              0
              • RIVOPICOR RIVOPICO

                i think the part the code is this:
                void MainWindow::generarVentanaChat()
                {
                /** Crea una ventana de chat **/
                this->chat = new QWidget(0,Qt::CustomizeWindowHint);
                this->capa = new QVBoxLayout(chat);
                this->capaHorizontal = new QHBoxLayout(chat);
                this->botonChatEnviar = new QPushButton("Enviar",chat);
                this->enviarChatTexto = new QLineEdit(chat);
                salidaChatTexto = new QPlainTextEdit(chat);
                capa->addWidget(salidaChatTexto);
                capaHorizontal->addWidget(enviarChatTexto);
                capaHorizontal->addWidget(botonChatEnviar);
                capa->addLayout(capaHorizontal);
                }
                You refer to this?

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @RIVOPICO said in Help with this message:

                void MainWindow::generarVentanaChat()
                this->capa = new QVBoxLayout(chat); // << your are setting the layout on the widget here
                this->capaHorizontal = new QHBoxLayout(chat); // << your are again setting a layout but it will fail.
                }

                Take a look at Qt's examples and demo. You'll see how to build your UI properly.

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

                RIVOPICOR 2 Replies Last reply
                2
                • RIVOPICOR Offline
                  RIVOPICOR Offline
                  RIVOPICO
                  wrote on last edited by RIVOPICO
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • Venkatesh VV Venkatesh V

                    Hai...
                    I think you are using QmainWindow, that already have layout.... so instead of using QMainWindow you just use QWidget.... or else if you wanted to use QmainWindow than you do one thing first you take one Qwidget object and set that widget as centralwidget and after that you can set layout to widget Object...

                    for example:

                    Qwidget *w=new Qwidget;
                    setCentralWidget(w);
                    QHboxLayout *lyt= new QHboxLayout;
                    w->setLayout(lyt);
                    //then add your all the widget to layout this will work
                    lyt->addwidget(widget1)
                    lyt->addwidget(widget2)
                    lyt->addwidget(widget3)

                    RIVOPICOR Offline
                    RIVOPICOR Offline
                    RIVOPICO
                    wrote on last edited by RIVOPICO
                    #9
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • SGaistS SGaist

                      @RIVOPICO said in Help with this message:

                      void MainWindow::generarVentanaChat()
                      this->capa = new QVBoxLayout(chat); // << your are setting the layout on the widget here
                      this->capaHorizontal = new QHBoxLayout(chat); // << your are again setting a layout but it will fail.
                      }

                      Take a look at Qt's examples and demo. You'll see how to build your UI properly.

                      RIVOPICOR Offline
                      RIVOPICOR Offline
                      RIVOPICO
                      wrote on last edited by RIVOPICO
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • SGaistS SGaist

                        @RIVOPICO said in Help with this message:

                        void MainWindow::generarVentanaChat()
                        this->capa = new QVBoxLayout(chat); // << your are setting the layout on the widget here
                        this->capaHorizontal = new QHBoxLayout(chat); // << your are again setting a layout but it will fail.
                        }

                        Take a look at Qt's examples and demo. You'll see how to build your UI properly.

                        RIVOPICOR Offline
                        RIVOPICOR Offline
                        RIVOPICO
                        wrote on last edited by RIVOPICO
                        #11

                        Some way to do with qmainwindows with widget take me errors.
                        'SetCentralWidget': no se encontr¢ el identificador
                        'addwidget' : no es un miembro de 'QHBoxLayout'

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Because you are writing the name of the functions wrong. They are case sensitive.

                          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
                          1

                          • Login

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