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

Getting .exe stopped working when i try to clear textedit ...??



  • hello,
    here im dragging text content of "textedit" to "textedit_2" and when "textedit_2" gets text content i will send it through tcp/ip communication to receiver after sending i have to clear "textedit_2 " but when i attempt to do so im getting .exe stopped working. can anyone solve this problem.....??

    @
    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::on_textEdit_2_textChanged()
    {

    sendsocket = new QTcpSocket(this);
    QString hostaddress="127.0.0.1";
    sendsocket->connectToHost(hostaddress,1234);
    QString str=ui->textEdit_2->toPlainText();
    
     sendsocket->write(qPrintable(str));
     ui->textEdit_2->clear();-------------------------------------> // if i include this line its showing .exe stopped working           message //
    

    }
    @


  • Moderators

    Hi,

    Your code has memory corruption. This can happen for many reasons, such as if you forget to initialize a pointer, or if use a pointer after it has been deleted.

    Use a debugger to run your program (make sure you build it in Debug mode). It will give you more clues on where the memory corruption occurs.

    Also, please add '@' before and after your code to make it easier to read.


Log in to reply