QLayout Problem [gelöst]

Alles rund um die Programmierung mit Qt
Antworten
strige
Beiträge: 36
Registriert: 27. Dezember 2009 19:37

QLayout Problem [gelöst]

Beitrag 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
Zuletzt geändert von strige am 26. Juni 2012 11:10, insgesamt 1-mal geändert.
franzf
Beiträge: 3114
Registriert: 31. Mai 2006 11:15

Re: QLayout Problem

Beitrag 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);
}
strige
Beiträge: 36
Registriert: 27. Dezember 2009 19:37

Re: QLayout Problem

Beitrag von strige »

Ach :D
Danke Dir! Problem gelöst:)
Antworten