Deathshadow
27th February 2018, 06:48
The mainwindow header looks like:
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;
};
Mainwindow source looks like:
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;
}
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.
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;
};
Mainwindow source looks like:
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;
}
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.