Add textedit dynamically



  • how can i add textedit dynamically to different position in my workspace on clicking a push button.



  • @sanjay1155

    Hi, friend, welcome devnet.

    You can new QTextEdit object and set parent. then, set resize and move position. like the following code:

    #include "dialog.h"
    #include "ui_dialog.h"
    
    #include <QTextEdit>
    
    Dialog::Dialog(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Dialog)
    {
        ui->setupUi(this);
    }
    
    Dialog::~Dialog()
    {
        delete ui;
    }
    
    void Dialog::on_btn_clicked()
    {
        QTextEdit *edit = new QTextEdit(this);
        edit->resize(200,40);
        edit->move(10,10);
        edit->show();
    }
    

Log in to reply
 

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