Seite 1 von 1

QLayout Problem [gelöst]

Verfasst: 26. Juni 2012 09:37
von strige
Hi zusammen,
Ich seh den Wald vor lauter Bäumen nicht :roll:
bekomme beim kompilieren immer folgende Fehlermeldung:
QLayout: Attempting to add QLayout "" to InWidget "", which already has a layout
QLayout: Attempting to add QLayout "" to InWidget "", which already has a layout
QLayout: Attempting to add QLayout "" to InWidget "", which already has a layout
das der Code:

Code: Alles auswählen

 hBox = new QHBoxLayout(this);
    setLayout(hBox);
    QLabel *month = new QLabel("Gesamt:  €", this);
    month->setFrameStyle(QFrame::Panel | QFrame::Raised);

    box = new QGroupBox("Monatliche Einnahmen", this);
    ibx = new QVBoxLayout(this);
    set = new QPushButton("+", this);


    box->setLayout(ibx);
    lVbox = new QVBoxLayout(this);
    lVbox->addWidget(box);
    lVbox->addWidget(month);
    for (int i = 0; i< 3; i++){
        QLabel *l = new QLabel(QString("Label %1").arg(i), box);
        ibx->addWidget(l);
    }


    rVbox = new QVBoxLayout(this);
    rVbox->addWidget(set,3);

    hBox->addLayout(lVbox);
    hBox->addLayout(rVbox);
Mein Ziel ist es zwei Verticale Layouts in ein Horizointales Layout zubringen.
Freue mich auf Antwort :D
Lg

Re: QLayout Problem

Verfasst: 26. Juni 2012 09:55
von franzf
Übergibst du ein parent an den Layout-Konstruktor, wird das Layout dort gleich gesetzt; siehe QLayout-Quelltext (@<qt-src>/src/gui/kernel/layout.cpp):

Code: Alles auswählen

QLayout::QLayout(QWidget *parent)
    : QObject(*new QLayoutPrivate, parent)
{
    if (!parent)
        return;
    parent->setLayout(this);
}

Re: QLayout Problem

Verfasst: 26. Juni 2012 11:07
von strige
Ach :D
Danke Dir! Problem gelöst:)