0

Because of some bug in QtDesigner integrated into QtCreator 2.4.1 I created separated definition as a class inheriting from QWidget. This solve the problem with lying out widgets in Layouts on pages of QStackedWidget. Additionally this nicely separate complex UI.

However with this solution I fall into problem of main form and the page being separate classes. In the inner class I do not see elements (widgets, slots) of the main form/window, while the logic requires operations there (enabling/disabling some buttons, binding popups, etc.)

I am looking for a good pattern how such problem should be solved. I tried follow some advices found on Google with accessing through parent pointer, however I failed and crashed the application :-) This is not what I am looking for.

Michał Fita
  • 1,183
  • 1
  • 7
  • 24

1 Answers1

0

Typical Qt-way of solving such a problem is done via signals.

In your case you can emit signals with some data from page, while main form has an associated function(-s) connected to the object signals. Something like:

Definition

class page : public QObject
{
     Q_OBJECT

...

    signals:
        void my_custom_signal(int value);
};

Implementation

void page::function()
{
    // some code

    emit my_custom_signal(FORM_SHOW_ABOUT_DIALOG);
}
Andrejs Cainikovs
  • 27,428
  • 2
  • 75
  • 95