PDA

View Full Version : stackedWidget



dragon
16th October 2007, 17:39
Hello Anyone,

Iám using Qt-4.2.2
I have a MainWindow with QStackedWidget.
This is a little example ( there is a bigger program.)
On the stackWidget i have 2 pages.
On page 1 with LineEdits ( name and Adress ) and pushbutton(Next). currentIndex(0)
On page 2 i have also 2 LineEdits ( for typing the name and adress) and also a pushbutton(Back). currentIndex(1);
With the pushbutton(back i can go back to currentIndex(0);
On page 2 i type the name and adress in the lineedits and push the pushbutton(Back).
Now my question is what i type in the lineedits i want to see it back on page 1 in the lineedits is this possible.
Now i see nothing in the lineedits on page 1.

Thanks in advance.

Tux-Slack
16th October 2007, 22:14
Sure it's posible.
QString name;
name = line2Edit->text();
line1Edit->setText(name);

Or you can omit declaring a new variable just for that:
line1Edit->setText(line2Edit->text());

dragon
17th October 2007, 16:56
The first solution doesn't work for me in stackedWidget
QString name;
name = line2Edit->text();
line1Edit->setText(name);

The second solution work for me in stackedWidget
I can only omit declaring a new variable.
line1Edit->setText(line2Edit->text());

What about omit declaring a new variable for QTableWidgetItem.
On my third page i have a TableWidget with items.
I want select a item like this:


QTableWidgetItem *item = table->currentItem();
if( item->isSelected()) {
QString name = item->text();
}

But i can't use the string variable name because stackedWidget doesn't see the variable in the line1Edit on page 1.(the same as first solution).

dragon
18th October 2007, 16:05
I have solved it.
It works fine now.