I have strange behaviour while using an array of QTextEdit widgets.
-
wrote on 20 Apr 2022, 16:39 last edited by
I have implemented an array of QTextEdit boxes as follows:
QTextEdit* ntr_array[45];
ntr_array[1] = ui->textEdit_1;
I have a std::vector std::stringmyvector containing 45 text words of type std::string
Then I do this
Qstring tempstr = QString::fromStdString(myvector[1]);
ntr_array[1]->setText(tempstr);This compiles and when executed will seg fault at the last line: ntr_array[1]->setText(tempstr);
I've tried substituting
ui->textEdit_1->setText(tempstr);It still seg faults on this line.
I am using QT 4.8
QtCreator 3.2.2
on linux Fedora.Thanks for any help
-
wrote on 20 Apr 2022, 17:39 last edited by
Run the debugger !
However, ui->textEdit_1; looks like an invalid pointer ... -
wrote on 20 Apr 2022, 18:47 last edited by
The editor auto finishes the ui->textEdit_1 line so the editor thinks it is valid. What should I look for in the debugger when I set the breakpoint at the line it seg faults at and it stops there??
-
The editor auto finishes the ui->textEdit_1 line so the editor thinks it is valid. What should I look for in the debugger when I set the breakpoint at the line it seg faults at and it stops there??
wrote on 20 Apr 2022, 19:16 last edited by JonB@emp1953
You could try puttingui->textEdit_1
into the debugger's Watch window and having a look at what seems to be in it.I assume you created that in the designer. Have you done the
ui->setupUi()
call in your code? Make sure you have done a full rebuild. -
wrote on 20 Apr 2022, 19:59 last edited by
Yes ui->setup() happens
nutr[2] has a big hex number that looks like a pointer.I did a qmake on the .pro file and got a Makefile.
Did a 'make clean; make' now all is good. Apparently the clean function in qtCreator doesn't really function as advertisedThanks for the help
5/5