[SOLVED}Strange behaviour of initialization in constructor...
-
[quote author="DiIvPa" date="1398699896"]Why ? Take a look at declaration:
@ QString Modl_S_set[2][18][9];@[/quote]Oh, I overlooked that the one array is size 9, not 8.
So that's not the problem...
-
Update 2:
Replace:
@Modl_S_set[n_can][n_modl][8] == "ONN";@With:
@Modl_S_set[n_can][n_modl][8] = "ONN";@;-)
-
That's pity but I still need help....
-
[quote author="DiIvPa" date="1398700334"]That's pity but I still need help....[/quote]
To make it clear again:
You must use assignment operator instead of equality operator!
-
Thank you very much. I lost a couple hours to figure out this. I appreciate your help. (Fresh eye is quick sometimes..)
-
[quote author="DiIvPa" date="1398700558"]I lost a couple hours to figure out this.[/quote]
I've been trough this many times :-)
-
Hi,
On a side note, you have a memory leak in your main, you don't delete my_widget before ending the main function.
-
Hi, SGaist, thank you for a side note. It would be nice if you explain me a little more detailed what do you mean. I thought that in main I haven't do anything exept issueing
@my_widget -> show();@In myWidget class I keep an eye on it and make appropriate deletes. What have I to do in main ? Do I need to make
@delete my_widget;@
after issueing
@my_widget -> show();@
I tryed and found that the window disappeared from screen as I expected. Maybe you mean something else ?
-
Let's use your application as the example:
Following your technique:
@int main(int argc, char **argv){
QApplication app(argc, argv);
myWidget *my_widget = new myWidget; << heap allocationmy_widget -> show();
int ret = app.exec();
delete my_widget; << delete once it's done
return ret;
}@The Qt way:
@int main(int argc, char **argv){
QApplication app(argc, argv);
myWidget my_widget; << stack allocation
my_widget.show();return app.exec();
}@ -
Hi, SGaist, thank you for explanation. I did as you recomended.