Qt World Summit: Register Today!

update Text in LineEdit on the Go

  • I am trying to update the text on my linedit every time I get a frame, but my program crash. I tried doing the same with a loop, but the window shows only after the loop has finished. setH() is my slot, in Debug mode it run perfectly, the problem is when trying to update the text in LineEdit while the programm is running(the mainwindow is on the screen) . Thank you
    void MainWindow::updatehand(){
    if (controller.isConnected()){
    int hc =frame.hands().count();
    QString hndc= QString::number(hc);
    emit hChanged(hndc);
    }void MainWindow::setH(const QString hndc){

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Did you properly initialize handsRead ?

  • Thank you for the answer,
    I initialize in the mainwindwo.h file
    QLineEdit *handsRead;

  • Lifetime Qt Champion

    You are declaring a pointer to a QLineEdit, that's not the initialization.

  • (Have only one post every 5 minutes, I am new Here)
    Yes, I did.
    connect(this, SIGNAL(hChanged(const QString)),
    this, SLOT(setH(const QString)));
    handsRead = new QLineEdit();
    the text is updated only before the mainwindow is shown, after that if I try to update handsRead, the program crash, it is receiving information constantly

Log in to reply