PDA

View Full Version : QlineEdit - restoring text from hide/closed window.



Wojtek1990
24th July 2010, 01:51
Hi.

I've searched a lot but I can't find answer how to do it... I've done by Qt Designer signal/slot which call window hide () function after click on OK button... but after opening this window again by code:

App *app = new App(this);
app->show();


QlineEdit object text is empty - don't save written by me text, is restored to default state (Qline object projected in QtDesigner as empty at start). What to do to always display text which I've writtem in this Qline object ?


1.


void App::on_OK_clicked()
{
(ui->message)->setText(oldMessage);
}


don't work.

2. slot/signal which make update () function on QLine when OK button pressed in Qt designer also ...

saa7_go
24th July 2010, 02:52
Can you post more complete code?

Wojtek1990
24th July 2010, 17:49
Problem seems to be in this code:


Tasker *tasker = new Tasker(this);
tasker->show();


It open new window with default object values. How to open ALREADY HIDDEN window ?

When I use function Tasker::show(); in file tasker.cpp it works - window is restored to state before hidding.
But when I use this function in mainwindow.cpp file



void MainWindow::on_actionTasker_activated()
{
if (OpenFirstTime == 0) {
Tasker *tasker = new Tasker(this);
tasker->show();
OpenFirstTime=1;
}
else {
//Tasker d;
//d.show(); -> open window just for second
Tasker::show(); // makes error
}
}


I got error:



Cannot call member function 'Void QWidget::show()' without object


How to solve it ?

wysota
25th July 2010, 03:06
but after opening this window again by code:

App *app = new App(this);
app->show();


QlineEdit object text is empty
It's not the same window. It's a similar window.

If you want to retrieve the data from the closed window, you have to access variables corresponding to this particular window instead of creating a new one.

Wojtek1990
25th July 2010, 14:03
you have to access variables corresponding to this particular window instead of creating a new one.

By pointers ? How to do it ? Could anyone post example ?

wysota
25th July 2010, 14:41
Hmm... what are your C++ skills? Can you tell a difference between a class and an object?