Results 1 to 3 of 3

Thread: Inputting Into Lists

  1. #1
    Join Date
    Mar 2011
    Qt products

    Default Inputting Into Lists

    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:
    Qt Code:
    1. void ReceiptProgram::buttonClickHandler()
    2. {
    3. ui->itemLabel->setText(ui->itemLine->text());
    4. ui->priceLabel->setText(ui->priceLine->text());
    5. }
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance,

  2. #2
    Join Date
    Mar 2009
    Brisbane, Australia
    Thanked 1,579 Times in 1,508 Posts
    Qt products
    Qt4 Qt5
    Unix/X11 Windows
    Wiki edits

    Default Re: Inputting Into Lists

    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?

  3. #3
    Join Date
    Mar 2011
    Qt products

    Default Re: Inputting Into Lists

    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,

Similar Threads

  1. Hi all, some about lists and views
    By kosasker in forum Newbie
    Replies: 4
    Last Post: 24th January 2011, 12:55
  2. Replies: 2
    Last Post: 27th November 2008, 10:16
  3. display lists
    By rick_st3 in forum Newbie
    Replies: 3
    Last Post: 22nd June 2008, 23:09
  4. Some problems with lists
    By gdiepen in forum Qt Programming
    Replies: 9
    Last Post: 16th January 2008, 16:54
  5. When sort the lists?
    By SkripT in forum Qt Programming
    Replies: 6
    Last Post: 14th April 2006, 16:30


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.