Jul 3, 2022 at 9:05pm
I need help. How can i fix that.I am getting a stackoverflow. I want to swap the names of my labels by pressing the swapLabels Button.
1 2 3
|
QString A=ui->LabelRight->text();
on_swapLabels_clicked();
ui->LabelLeft->setText(A);
|
Last edited on Jul 3, 2022 at 9:06pm
Jul 3, 2022 at 9:57pm
"segmetation fault" means you are trying to access an invalid memory address.
This most commonly happens by dereferencing a "dangling" (invalidated) or uninitialized pointer.
But it's impossible to say with this small code excerpt what your particular problem is...
There is nothing obviously wrong in this code excerpt, but what does on_swapLabels_clicked()
do?
Last edited on Jul 3, 2022 at 9:59pm
Jul 3, 2022 at 10:28pm
on_swapLabels_clicked() swaps the labels.
for example.
Label1= Hello , Label2=World
if i press on_swapLabels_clicked()
the labels swap!
Label1=World , Label2=Hello
Last edited on Jul 3, 2022 at 10:28pm
Jul 3, 2022 at 11:17pm
How does on_swapLabels_clicked()
know what label to swap?
If you're getting "a stack overflow", then you likely have infinite recursion somewhere.