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){
MainWindow::handsRead->setText(hndc);
m_hands++;
updatehand(); -
Hi and welcome to devnet,
Did you properly initialize handsRead ?
-
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();
handsRead->setMaximumWidth(40);
handsRead->setDisabled(1);
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