An example in pseudo code (I didn't check it for syntactical errors).
mymainwindow.h
{
Q_OBJECT
public
explicit MyMainWindow(...);
~MyMainWindow();
public slots: //or protected
void connect();
};
class MyMainWindow : public QMainWindow
{
Q_OBJECT
public
explicit MyMainWindow(...);
~MyMainWindow();
public slots: //or protected
void connect();
void connectTo(const QString &server, const QString &port, const QString &nick, const QString &channel);
};
To copy to clipboard, switch view to plain text mode
mymainwindow.cpp
MyMainWindow::MyMainWindow(...) :
{
// Create your controls, like a menu, buttons, etc...
connect(connectAction /*or button*/, SIGNAL(clicked()), this, SLOT(connect()));
}
void MyMainWindow::connect()
{
MyConnectDialog connectDialog;
connectDialog.exec();
}
{
// Do the actual connection here based on the settings.
}
MyMainWindow::MyMainWindow(...) :
QMainWindow(...)
{
// Create your controls, like a menu, buttons, etc...
connect(connectAction /*or button*/, SIGNAL(clicked()), this, SLOT(connect()));
}
void MyMainWindow::connect()
{
MyConnectDialog connectDialog;
connect(&connectDialog, SIGNAL(newConnection(QString, QString, QString, QString)), this, SLOT(connectTo(QString, QString, QString, QString)));
connectDialog.exec();
}
void MyMainWindow::connectTo(const QString &server, const QString &port, const QString &nick, const QString &channel)
{
// Do the actual connection here based on the settings.
}
To copy to clipboard, switch view to plain text mode
myconnectdialog.h
class MyConnectDialog
: public QDialog{
Q_OBJECT
public:
explicit MyConnectDialog(...);
~MyConnectDialog();
protected slots:
void makeConnection();
signals:
};
class MyConnectDialog : public QDialog
{
Q_OBJECT
public:
explicit MyConnectDialog(...);
~MyConnectDialog();
protected slots:
void makeConnection();
signals:
void newConnection(const QString &server, const QString &port, const QString &nick, const QString &channel);
};
To copy to clipboard, switch view to plain text mode
myconnectdialog.cpp
MyConnectDialog::MyConnectDialog(...) :
{
...
connect(done, SIGNAL(clicked()), this, SLOT(makeConnection()));
...
}
void MyConnectDialog::makeConnection()
{
emit newConnection(serverLine->text(), ...);
}
MyConnectDialog::MyConnectDialog(...) :
QDialog(...)
{
...
connect(done, SIGNAL(clicked()), this, SLOT(makeConnection()));
...
}
void MyConnectDialog::makeConnection()
{
emit newConnection(serverLine->text(), ...);
}
To copy to clipboard, switch view to plain text mode
I hope this is clear.
Bookmarks