Solved Passing QString to function.
-
Hi, also you could try (this is just a guess) to go via a normal QString, like this:
{ QString name2(name); QGroupBox *brightnessSettings = new QGroupBox(name2); ... }
-
here have a look of debug result:
https://postimg.org/image/6g1fp20zb/ -
Something fishy:
settingsBackground = constructFrame(this, settingsBackground, 10, 145, 640, 320);
Frankly the code itself looks like its doing pretty strange thing to setup the widget.
-
I don't think anything is fishy with constructFrame(); why would you think that ?
constructFrame definition:
QFrame* EyeCare::constructFrame(QWidget *parent, QFrame *frameName, int x, int y, int w, int h, QString style) { frameName = new QFrame(parent) ; frameName->setGeometry(x,y,w,h); if (!style.isEmpty()) frameName->setStyleSheet(style); return frameName ; }
I don't think there is anything wrong with it because i am using it with other places in my code and i have no issue with it.
What you think is strange please be specific ?
btw this is what i am trying to achieve with the code :
-
@Ahti Hi, looking at https://postimg.org/image/6g1fp20zb/ it seems that inside createBrightnessSettings you call createBrightnessSettings 2 times (one for "Day Mode" and one for "Night Mode") so that first time there are 2 calls, then 4, then 8, then 16 etc.... When recursive-calling yourself you need some mechanism to stop otherwise the program will crash :-(
-
@hskoglund but at the end it has a return statement which would return the "brightnessSettings" QGroupBox pointer this is where stopping mechanism for recursive call happens returning from every call would ultimately bring it out of the createBrightnessSettings() function .
-
Then why pass frameName as argument to that function ?
-
@SGaist I am creating more than one frame that is why i have to pass the name of the frame that i want to create.
like for example :
homeBackground = constructFrame(this,homeBackground,10,145,640,320) ; settingsBackground = constructFrame(this,settingsBackground,10,145,640,320) ; topSeperator = constructFrame(contactBackground,topSeperator,5,60,635,2,"background-color:white;") ; ...
-
This post is deleted! -
@Ahti well the recursiveness is still fatal, createBrightnessSettings("Night Mode",...) is never reached, instead createBrightnessSettings("Day Mode"... is calling itself many millions of times then the app crashes because of stack overflow.