Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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 ???



  • 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