Dynamically add qtextedits



  • How can i dynamically add qtextedits to a qframe when i click on the button present outside that qframe and also if these qtextedits increases and get beyond the width or height of the qframe then automatically the scollbars should appear how can i implement this ???


  • Moderators

    Hi! You need to set a layout for the the frame and then add the textedits to that layout. By default, QFrame shows a horizontal and a vertical scrollbar when needed, but you can change the scrollbar behaviour with horizontalScrollBarPolicy and verticalScrollBarPolicy properties.

    void MyWindow::on_pushButton_clicked()
    {
        auto vl = new QVBoxLayout(ui->frame);
        auto te = new QTextEdit(ui->frame);
        vl->addWidget(te);
        te->show();
    }
    

Log in to reply
 

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