Sorry, I had a hard time putting this problem into words.
I figured it out on my own... finaly. I was not aware that one could create one's own protection level keywords and when I was looking at the help files I didn't notice the
public slots:
public slots:
To copy to clipboard, switch view to plain text mode
keyword.
I created a canonical version of the solution which I will now post for posterity
...
Errrr... Well, I can't seem to attach the file.
I guess I'll just try to summarize what I did here.
I created a "Main Window" form in the Qt Designer and changed it's object name to "QT_DesignerTestWindow". I added a menu item called "Launch some dialog box". The designer automatically created the action "actionLaunch_some_dialog_box".
I also created a Dialog and changed its object name to "SomeDialog".
I used qmake to create the .h files.
I created a main.cpp shown below.
I created a class derived from QMainWindow called MyMainWindow and added a function to that class in the 'private slots' protection level scope to act as my custom 'slot' (event callback function) also shown below.
Here is the code:
// main.cpp
#include <QApplication>
// include the Designer derived header
#include "ui_QT_designer_test.h"
// include the QMainWindow subclass header
#include "MyMainWindow.h"
int main(int argc, char *argv[])
{
MyMainWindow* mainWin = new MyMainWindow();
Ui::QT_DesignerTestWindow designerTestWindow;
designerTestWindow.setupUi(mainWin);
// attempt to setup the slot to show the dialog box
QObject::connect(designerTestWindow.
actionLaunch_some_dialog_box,
SIGNAL(triggered()),
mainWin, SLOT( showDialog() ));
mainWin->show();
return app.exec();
}
// main.cpp
#include <QApplication>
// include the Designer derived header
#include "ui_QT_designer_test.h"
// include the QMainWindow subclass header
#include "MyMainWindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyMainWindow* mainWin = new MyMainWindow();
Ui::QT_DesignerTestWindow designerTestWindow;
designerTestWindow.setupUi(mainWin);
// attempt to setup the slot to show the dialog box
QObject::connect(designerTestWindow.actionLaunch_some_dialog_box,
SIGNAL(triggered()),
mainWin, SLOT( showDialog() ));
mainWin->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
// MyMainWindow.h
#ifndef MYMAINWINDOW_H
#define MYMAINWINDOW_H
#include <QMainWindow.h>
{
Q_OBJECT
public:
MyMainWindow();
private slots:
void showDialog();
};
#endif
// MyMainWindow.h
#ifndef MYMAINWINDOW_H
#define MYMAINWINDOW_H
#include <QMainWindow.h>
class MyMainWindow : public QMainWindow
{
Q_OBJECT
public:
MyMainWindow();
private slots:
void showDialog();
};
#endif
To copy to clipboard, switch view to plain text mode
// MyMainWindow.cpp
#include "mymainwindow.h"
#include "ui_SomeDialogBox.h"
MyMainWindow::MyMainWindow( )
{
}
void MyMainWindow::showDialog()
{
Ui::SomeDialog dialog;
dialog.setupUi(showMe);
showMe->show();
}
// MyMainWindow.cpp
#include "mymainwindow.h"
#include "ui_SomeDialogBox.h"
MyMainWindow::MyMainWindow( )
: QMainWindow()
{
}
void MyMainWindow::showDialog()
{
QDialog* showMe = new QDialog();
Ui::SomeDialog dialog;
dialog.setupUi(showMe);
showMe->show();
}
To copy to clipboard, switch view to plain text mode
Bookmarks