Hi everyone!
My problem is seems to be similar as jayw710's so I didn't opened a new topic.
I'm designing an application what have a main window.
This was designed in the QT Designer.
I'm subclassed it with the QDevelop IDE to the mainwindowimpl.cpp , .h
It generated the MainWindowImpl class.
I was designed an other dialog whit the designer, subclassed it in the same way.
This is created the smenu.cpp and the smenu.h header file with the settingsmenu class.
I have inculded the smenu.h into the mainwindow.h.
In the class definition of the MainWindowImpl, I created a pointer to the dialog.
class MainWindowImpl
: public QMainWindow,
public Ui
::FoAblak{
Q_OBJECT
public:
MainWindowImpl
( QWidget * parent
= 0, Qt
::WFlags f
= 0 );
~MainWindowImpl();
Ui::FoAblak ui;
smenu *settingsMenu;
int volume;
class MainWindowImpl : public QMainWindow, public Ui::FoAblak
{
Q_OBJECT
public:
MainWindowImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
~MainWindowImpl();
Ui::FoAblak ui;
smenu *settingsMenu;
int volume;
To copy to clipboard, switch view to plain text mode
In the constructor of the MainWindowImpl I create an object from it.
MainWindowImpl
::MainWindowImpl( QWidget * parent, Qt
::WFlags f
) {
_mixerfd = open("/dev/mixer", O_RDWR);
ui.setupUi(this);
smenu = new settingsMenu(this);
...
void doSomething()
{
qWarning() << "it work's";
};
MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
: QMainWindow(parent, f)
{
_mixerfd = open("/dev/mixer", O_RDWR);
ui.setupUi(this);
smenu = new settingsMenu(this);
...
void doSomething()
{
qWarning() << "it work's";
};
To copy to clipboard, switch view to plain text mode
When I press a button in the main window I call the smenu->show()
The dialog appears, and everything is fine.
But -- and there is my big problem -- I would like to acces from this dialog the MainWindow 's functions, variables, etc.
I know that I have to do something with the constructor's first argument the parent pointer.
For example I can access the mainwindow's width with the parent->width(), but I can not do it with the parent->doSomething().
I would like to ask it from you how can I do it?
Bookmarks