cooper
8th March 2011, 03:24
Hi everyone,
I need open a new dialog (form) from main form.
void MainScr::on_pushButton_2_clicked()
{
if (!cyclescrdialog)
cyclescrdialog = new cycleScrDialog(NULL);
cyclescrdialog->exec();
}
in the beginning of the new form, i initialize two leds, "label_led_1" and "label_led_2", to be green.
cycleScrDialog::cycleScrDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::cycleScrDialog)
{
ui->setupUi(this);
QPoint pos; // relocate window
pos.setX(0); // x
pos.setY(0); // y
move(pos);
picLedRed = QPixmap("/home/Pictures/ledred.png");
picLedGreen = QPixmap("/home/Pictures/ledgreen.png");
ui->label_led_1->setPixmap(picLedGreen);
ui->label_led_2->setPixmap(picLedGreen);
// ....
// ....
}
cycleScrDialog::~cycleScrDialog()
{
delete ui;
}
// exit button
void cycleScrDialog::on_pushButton_4_clicked()
{
close();
}
in the middle of program, these leds will be changed to be red.
after i click "exit" button to close this window (dialog), and re-open it, I found that these two leds are still red.
When i step through my program, it did not go through the beginning of cycleScrDialog. it means that the close() function does not close completely, all variables in cycleScrDialog has not been released from memory.
can anyone point me where i did wrong, and how to close a dialog properly?
Thanks in advance.
I need open a new dialog (form) from main form.
void MainScr::on_pushButton_2_clicked()
{
if (!cyclescrdialog)
cyclescrdialog = new cycleScrDialog(NULL);
cyclescrdialog->exec();
}
in the beginning of the new form, i initialize two leds, "label_led_1" and "label_led_2", to be green.
cycleScrDialog::cycleScrDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::cycleScrDialog)
{
ui->setupUi(this);
QPoint pos; // relocate window
pos.setX(0); // x
pos.setY(0); // y
move(pos);
picLedRed = QPixmap("/home/Pictures/ledred.png");
picLedGreen = QPixmap("/home/Pictures/ledgreen.png");
ui->label_led_1->setPixmap(picLedGreen);
ui->label_led_2->setPixmap(picLedGreen);
// ....
// ....
}
cycleScrDialog::~cycleScrDialog()
{
delete ui;
}
// exit button
void cycleScrDialog::on_pushButton_4_clicked()
{
close();
}
in the middle of program, these leds will be changed to be red.
after i click "exit" button to close this window (dialog), and re-open it, I found that these two leds are still red.
When i step through my program, it did not go through the beginning of cycleScrDialog. it means that the close() function does not close completely, all variables in cycleScrDialog has not been released from memory.
can anyone point me where i did wrong, and how to close a dialog properly?
Thanks in advance.