I'm sure this has been covered elsewhere but I can't seem to find anything recent so I'll ask.
Is there a preferred method or modifying an existing dialog? Are we expected to use Qt Designer or can I just hand edit the text files for simple things? If we are only to use Designer, should we be using Qt 4 or 5?
Thank you!
Modifying an existing dialog?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Modifying an existing dialog?
I use Designer for Qt4. The Qt5 migration isn't quite ready as far as I know.
Re: Modifying an existing dialog?
I asked this in a different thread because that's where the conversation meandered to but it's probably more appropriate to ask it here.
I've added a Pref checkbox to an existing dialog using Qt 4 Designer after I built and installed the widget library. After rebuilding my option is there and clickable, no issues.
However, I thought by using a PrefCheckbox widget that saving and restoring the state of the preference would be handled automatically but that does not seem to be the case. So that's my question: what's the proper procedure for saving, restoring, and accessing the current state of a preference?
I've added a Pref checkbox to an existing dialog using Qt 4 Designer after I built and installed the widget library. After rebuilding my option is there and clickable, no issues.
However, I thought by using a PrefCheckbox widget that saving and restoring the state of the preference would be handled automatically but that does not seem to be the case. So that's my question: what's the proper procedure for saving, restoring, and accessing the current state of a preference?
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Modifying an existing dialog?
As far as updating, the magic is in the red box. Access in C++hokieengr wrote: ↑Mon Jul 02, 2018 12:17 pm However, I thought by using a PrefCheckbox widget that saving and restoring the state of the preference would be handled automatically but that does not seem to be the case. So that's my question: what's the proper procedure for saving, restoring, and accessing the current state of a preference?
Code: Select all
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
m_sectionEdges = hGrp->GetBool("ShowSectionEdges", 0l);
m_handleFaces = hGrp->GetBool("HandleFaces", 1l);
Re: Modifying an existing dialog?
That's kind of what I figured and what I believe I did. I'll confirm when I get home. On your machine, if you add a new Gui::PrefCheckBox, fill out the magic red box, save, go into your build directory and fire off make (and make install I suppose depending on how you do it), does the resulting checkbox work? If you click it, click OK, and reopen the dialog--does the state automatically get saved? Is there another step or script I have to run to let the magic know about my new little box?
Thanks a ton for the C++ example. That will help a lot. No need for Python right now since I'm working in C++.
Thanks a ton for the C++ example. That will help a lot. No need for Python right now since I'm working in C++.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Modifying an existing dialog?
A couple of things I can think of off hand:hokieengr wrote: ↑Mon Jul 02, 2018 2:17 pm That's kind of what I figured and what I believe I did. I'll confirm when I get home. On your machine, if you add a new Gui::PrefCheckBox, fill out the magic red box, save, go into your build directory and fire off make (and make install I suppose depending on how you do it), does the resulting checkbox work? If you click it, click OK, and reopen the dialog--does the state automatically get saved? Is there another step or script I have to run to let the magic know about my new little box?
Code: Select all
void DlgPrefsTechDrawImp::saveSettings()
{
cb_HidLine->onSave();
cb_Angle->onSave();
cb_Faces->onSave(); //<<<<<<<
cb_SectionEdges->onSave();
cb_PageUpdate->onSave();
pcb_Normal->onSave();
...
...
void DlgPrefsTechDrawImp::loadSettings()
{
cb_HidLine->onRestore();
cb_Angle->onRestore();
cb_Faces->onRestore(); //<<<<<<<
cb_SectionEdges->onRestore();
cb_PageUpdate->onRestore();
pcb_Normal->onRestore();
Re: Modifying an existing dialog?
Of course I swear I did all that before posting but it worked this time....