create a child object with initial data
-
@megido
I can't go through it again. I said that your original way was fine, with no parametersForm *AF = new Form; // here a few connects() AF->set_user_date(user_date); AF->show();
I told you that was fine. You then started saying the date was not initialised in the constructor. I replied:
I don't see what there is to say. Yes, the date is empty/default during the constructor, it gets changed to the desired date when the setter is called. What else would you expect, and what is the problem? Like I wrote, if you really need it to be set during the constructor you would have to add a parameter for it, but there is no obvious reason why you would need that.
You didn't say anything about why you have to have it initialized in the constructor. I do not see why you care about the log messages, they are no problem. You just started asking how to pass it as a parameter. So that is what I answered.
The best way is your original code. Answer why you care about when it is initilalized, what is unacceptable about this code?
-
@megido
I can't go through it again. I said that your original way was fine, with no parametersForm *AF = new Form; // here a few connects() AF->set_user_date(user_date); AF->show();
I told you that was fine. You then started saying the date was not initialised in the constructor. I replied:
I don't see what there is to say. Yes, the date is empty/default during the constructor, it gets changed to the desired date when the setter is called. What else would you expect, and what is the problem? Like I wrote, if you really need it to be set during the constructor you would have to add a parameter for it, but there is no obvious reason why you would need that.
You didn't say anything about why you have to have it initialized in the constructor. I do not see why you care about the log messages, they are no problem. You just started asking how to pass it as a parameter. So that is what I answered.
The best way is your original code. Answer why you care about when it is initilalized, what is unacceptable about this code?
@JonB yes, I have understood you. I too long time ago developed on Qt and forgot many. In this situation a just should call in the setter.
ui->dateedit->setDate(date);
but instead that I tried to update the variable before using it in the constructor. Because I thought what I really should predefine values in fields before the draw(It's usual for the WEB development).
-
@megido said in create a child object with initial data:
I have delete that. it was a private void
Why not making it public and use instead of deleting?