PDA

View Full Version : Inputting Into Lists



kiyoutee
2nd March 2011, 04:33
Hi all,

I am a complete newb at Qt and i'm trying to create a situation where i can input 2 Qstrings into a ListView and then keep on adding the pair of Qstrings to the list everytime the user clicks a PushButton. I have a ButtonHandler function that allows the Qstrings to be moved to the ListView. The 2 inputs are through 2 separate LineEdits.

The problem I am having is that once the first pair is input into the ListView whenever i change the values in the LineEdits and pres the PushButton the values already in the ListView change, it doesn't add a new pair to the ListView. Can anybody help me to change this (i'm not even sure how the LineEdits are pointing to the List)?

Here is the code from my ButtonHandler function:


void ReceiptProgram::buttonClickHandler()
{
ui->itemLabel->setText(ui->itemLine->text());
ui->priceLabel->setText(ui->priceLine->text());
}


Thanks in advance,

ChrisW67
2nd March 2011, 04:58
You are asking Qt to take the value from each QLineEdit and set the text of a corresponding QLabel (I assume). There's nothing here that seems to be related to a list.

What is a ListView? Do you mean QListView, QListWidget, or something else? Have you placed the widget in the UI?

kiyoutee
2nd March 2011, 07:48
Sorry, I was unclear. What I'm trying to do is just put the QLineEdit text into a QListView. I'm not sure how to get that text from the QLineEdit into the QListView. The widget is in the UI. The labels aren't involved (I'm not syre why they're in the code).

Thanks again,