Help with this message
-
@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 -
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? -
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.
-
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) -
@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.
-
This post is deleted!
-
Because you are writing the name of the functions wrong. They are case sensitive.