freesix
14th December 2015, 18:21
Hello, please I need help.
I have my MainWindow and my Dialog, both created with QDesigner.
My MainWindow possesses a QTextEdit entitled 'textEdit' and my Dialog has a
QPushButton named 'clickOk'
My concern is when I click on that QPushButton of my Dialog that he clears everything I wrote in the textEdit using
'clear()' method of QTextEdit.
Of course I use signal and slot but it's not working, I mean when I click on QPushButton nothing occurs in the textEdit
of my MainWindow.
by the way, I use modeless to show my Dialog using 'show()' method and it's works perfectly:
this is the code
----------------
QDialog *dlg = new QDialog(this);
dlg->show();
I don't want to use modal with '.exec()' function as I want the user to still use both at the same time.
Below's my implementation for everything (the two Forms) :
IMPLEMENTATION
==============
MainWindow.h
------------
public slots:
void clearText();
MainWindow.cpp
--------------
void MainWindow::clearText()
{
ui->textEdit->clear();
//QMessageBox::information (this, "TITLE", "WORKING = OK");
}
****************************
****************************
Dialog.h
--------
Private or Pulic slots: // even if I put it in public or private, it still doesn't work
void clearClick();
Dialog.cpp
--------
//in the constructor
connect(ui->clickOk, SIGNAL(clicked()), this, SLOT(clearClick()));
---
void QDialog::clearClick()
{
// I tried both methods below but nothing seems to happen
// First Method
QMainWindow dlg;
dlg.clearText();
// Second Method
QMainWindow *dlg = new QMainWindow();
dlg->cleanText();
}
PS : I tried to test if my ' void MainWindow::clearText() ' of the MainWindow works by inserting a QMessageBox in it,
when I click on QPushButton of the QDialog, and of course it really goes through that function, because the QMessageBox
appears when I execute the project... but 'ui->textEdit->clear();' doesn't work.
Thanks for your help in advance
I have my MainWindow and my Dialog, both created with QDesigner.
My MainWindow possesses a QTextEdit entitled 'textEdit' and my Dialog has a
QPushButton named 'clickOk'
My concern is when I click on that QPushButton of my Dialog that he clears everything I wrote in the textEdit using
'clear()' method of QTextEdit.
Of course I use signal and slot but it's not working, I mean when I click on QPushButton nothing occurs in the textEdit
of my MainWindow.
by the way, I use modeless to show my Dialog using 'show()' method and it's works perfectly:
this is the code
----------------
QDialog *dlg = new QDialog(this);
dlg->show();
I don't want to use modal with '.exec()' function as I want the user to still use both at the same time.
Below's my implementation for everything (the two Forms) :
IMPLEMENTATION
==============
MainWindow.h
------------
public slots:
void clearText();
MainWindow.cpp
--------------
void MainWindow::clearText()
{
ui->textEdit->clear();
//QMessageBox::information (this, "TITLE", "WORKING = OK");
}
****************************
****************************
Dialog.h
--------
Private or Pulic slots: // even if I put it in public or private, it still doesn't work
void clearClick();
Dialog.cpp
--------
//in the constructor
connect(ui->clickOk, SIGNAL(clicked()), this, SLOT(clearClick()));
---
void QDialog::clearClick()
{
// I tried both methods below but nothing seems to happen
// First Method
QMainWindow dlg;
dlg.clearText();
// Second Method
QMainWindow *dlg = new QMainWindow();
dlg->cleanText();
}
PS : I tried to test if my ' void MainWindow::clearText() ' of the MainWindow works by inserting a QMessageBox in it,
when I click on QPushButton of the QDialog, and of course it really goes through that function, because the QMessageBox
appears when I execute the project... but 'ui->textEdit->clear();' doesn't work.
Thanks for your help in advance