[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);
    
    mainLayout1->addLayout(row1);
    mainLayout1->addLayout(row2);
    
    QVBoxLayout *mainLayout2 = new QVBoxLayout;
    
    mainLayout2->addLayout(// a QTextBrowser);
    mainLayout2->addLayout(// a QPushButton);
    
    mysplitter->addWidget(mainLayout1);
    mysplitter->addWidget(mainLayout2);
    

    @

    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.