[SOLVED] how to align textEdit to the tabwidget tab_3



  • using the gui builder, in the mainwindow, i have a tabwidget aligned to a grid. when the user clicks a button, a new tab is created with a textEdit aligned to the grid of the tabwidget tab_3 in this example. the problem is that i can't use the gui builder to align the textEdit inside of the tabwidget tab_3 because tab_3 is not created yet. I need to write some code in the mainwindow.cpp file instead of using the gui builder.

    below is the code. it is my attempt to get the textEdit aligned in the tabwidget tab_3, but it is not working.

    @ QGridLayout *layout = new QGridLayout(this);
    textEdit->setParent(ui->tab_3);
    textEdit->setLayout(layout);
    textEdit->show();@



  • after 2 days searching the net, i finally discovered a solution by accident and shortly after i created this topic :). what i needed was the code below.

    @ QGridLayout *layout = new QGridLayout;
    textEdit->setParent(ui->tab_3);
    layout->addWidget(textEdit);
    ui->tab_3->setLayout(layout);
    textEdit->show();@


Log in to reply
 

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