The mainwindow header looks like:
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
private:
Ui::MainWindow *ui;
connection *con;
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
bool eventFilter(QObject *obj, QEvent *event);
~MainWindow();
private:
Ui::MainWindow *ui;
connection *con;
};
To copy to clipboard, switch view to plain text mode
Mainwindow source looks like:
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->lineEdit->installEventFilter(this);
QObjectList o_list = ui->lineEdit->children();
for(int i = 0; i < o_list.length(); i++)
{
QLineEdit *cast
= qobject_cast<QLineEdit
*>
(o_list
[i
]);
if(cast)
cast->installEventFilter(this);
}
}
{
if(event
->type
() == QEvent::MouseButtonPress) {
con->show();
}
return false;
}
MainWindow::~MainWindow()
{
delete ui;
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->lineEdit->installEventFilter(this);
QObjectList o_list = ui->lineEdit->children();
for(int i = 0; i < o_list.length(); i++)
{
QLineEdit *cast = qobject_cast<QLineEdit*>(o_list[i]);
if(cast)
cast->installEventFilter(this);
}
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::MouseButtonPress)
{
con->show();
}
return false;
}
MainWindow::~MainWindow()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
the Ui window contains a lineedit each.the connection window contains a textbox and the mainwindow contains another.The objective is to transfer the string/data from the widget window to main window using connect or any other method.
Bookmarks