Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Getters for UI-elements in generated UI-class #8

Open
cls-nebadje opened this issue Jun 13, 2016 · 2 comments
Open

Getters for UI-elements in generated UI-class #8

cls-nebadje opened this issue Jun 13, 2016 · 2 comments

Comments

@cls-nebadje
Copy link
Collaborator

Instead of exposing the actual pointers to the widgets, the generated UI-class should expose them through getters. This way we can prevent some self-injuries.

class Ui_foo
{
public:
    Wt::WContainerWidget *
    wt_root()
    {
        return m_wt_root;
    }
    ...
    Wt::WText *
    text()
    {
        return m_text;
    }
    void setupUi(Wt::WContainerWidget *PageRoot)
    {
        ...
    }
    ...
private:
    Wt::WContainerWidget *m_wt_root;
    Wt::WSlider *m_slider_volume;
    Wt::WPushButton *m_button;
    Wt::WText *m_text;
...
};

Regards
Uli

@juangburgos
Copy link
Owner

Hi,

This is the tool I used to inspire myself for WtDesigner. I did not invent my own way, I just adapted an existing idea to solve a new problem. Take look at it.

https://www.qt.io/ide/

This style follows the Qt style which might be good or might be bad but is the one that I know. QtDesigner does exactly the same and I was inspired by WtDesigner. Also other Qt developers are used to this style. Might not be the best option but I don't like re-inventing the wheel, so I think I will keep it this way.

Best.

@cls-nebadje
Copy link
Collaborator Author

Hi Juan,

no problem! I think your application has great potential so I try to contribute at least through feedback.

I generally try to rule out the greatest possible amount of bugs in my code by use of information hiding and other techniques which are considered good practice, aka "make interfaces easy to use correctly and hard to use incorrectly" (Scott Meyers). By exposing the data members any code can modify the pointers (even by accident) and cause obscure bugs.

Regards
Uli

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants