Qt World Summit: Register Today!

[Solved] QSplitter and QVBoxLayout problem

  • Hi,
    I have two QVBoxLayouts which have some widgets within them. I want to add a vertical splitter between the two. I am doing something wrong..please guide me. I am adding the code -

    QSplitter *mysplitter = new QSplitter(Qt::Vertical);
    QVBoxLayout *mainLayout1 = new QVBoxLayout;

    QHBoxLayout *row1 = new QHBoxLayout;
    row1->addWidget(//a QLabel);
    row1->addWidget(// a QLineEdit);
    QHBoxLayout *row2 = new QHBoxLayout;
    row2->addWidget(//a QLabel);
    row2->addWidget(// a QLineEdit);
    QVBoxLayout *mainLayout2 = new QVBoxLayout;
    mainLayout2->addLayout(// a QTextBrowser);
    mainLayout2->addLayout(// a QPushButton);


    As expected, the error is - no matching function for call to QSplitter::addWidget(QVBoxLayout...)

  • Hi,

    your bug is that layouts != widgets
    you have to put each layout on a widget and put the widgets into the splitter.

Log in to reply