Home » Community » Newbie corner » Problem in example code (Tried SplitterFrame yet minor problem.)
Re: Problem in example code [message #45950 is a reply to message #45946] |
Sat, 30 January 2016 16:37 |
|
dolik.rce wrote on Sat, 30 January 2016 14:03Hi,
I'm still not sure it is really good idea to this dynamically, but here is a working method: void StoreToJson() {
Json json;
for (Ctrl *q = GetFirstChild(); q; q=q->GetNext()) {
if (dynamic_cast<EditField *> (q)) {
String id = q->GetLayoutId();
if (id.GetCount())
json(id, ~*q);
}
}
SelectFileOut out("*.*");
if (out.IsOpen())
out << json << "\n";
}
It is actually almost the same as the code you posted. Full code is in the attached archive. Just click anywhere in the window to trigger the save as dialog. I'm not sure why it didn't work for you. Only thing I can think of is that you didn't assign names to the editfields in the layout.
Honza
Dear Honza,
Thanks a lot. Your technique for SelectFileOut is working and one file is created while the content is "{}". It means json content was not made. Probably you are right that dynamic_cast is not working. EditFields have dedicated names. Here "if (dynamic_cast<EditField *> (q)) { " is not true.
Is there any other way to bypass dynamic_cast?
best
Abhi
|
|
|
Goto Forum:
Current Time: Fri Nov 01 00:23:25 CET 2024
Total time taken to generate the page: 0.02673 seconds
|