Results 1 to 10 of 10

Thread: Problem with QList

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2013
    Posts
    5
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Problem with QList

    Hello everyone,

    I'm relatively new to Qt and to programming as a whole. So be clement

    My system is Windows 7, I am using Qt 5.1 with MinGW 32bit.

    My problem:

    I have a dialog that reads data from an sqlite database and writes it in a QList object. This QList contains objects of a C++ class I created (the class is called 'Card' and contains eight different QStrings).

    Qt Code:
    1. QList<Card*>* newcard = new QList<Card*>;
    To copy to clipboard, switch view to plain text mode 

    I have one label on my dialog that should display a QString from the first object of my QList.

    Qt Code:
    1. ui->textlabel->setText(newcard->takeAt(0)->getfront());
    To copy to clipboard, switch view to plain text mode 

    This works fine, the label is correctly displaying the QString. But then I want to change the text of the label when clicking a pushbutton.

    Qt Code:
    1. void MyDialog::on_pushbutton_clicked()
    2. {
    3. ui->textlabel->setText(newcard->takeAt(0)->getback());
    4. }
    To copy to clipboard, switch view to plain text mode 

    And this produces a SIGSEGV and the program crashes. I tried to fix the problem with different approaches, but none of them worked. The following code works neither:

    Qt Code:
    1. QMessageBox::information(this,"Title",QString::number(newcard->count()));
    To copy to clipboard, switch view to plain text mode 

    I also cannot transmit the QList to another dialog and work with it there. It crashes as well.


    I think this problem has a simple solution and I am just to much of an amateur to see that. Please help me!

    Well this thread should probably be in the newbie section, but I don't know how to move the thread...sorry.
    Last edited by just-in; 22nd August 2013 at 11:32.

Similar Threads

  1. Replies: 4
    Last Post: 20th August 2010, 13:54
  2. QList problem
    By frenk_castle in forum Newbie
    Replies: 1
    Last Post: 19th January 2010, 05:40
  3. Problem with QList
    By Gargolissimus in forum Newbie
    Replies: 8
    Last Post: 6th July 2009, 16:24
  4. QList problem
    By lvi in forum Qt Programming
    Replies: 3
    Last Post: 25th August 2008, 18:22
  5. QList problem
    By acix in forum General Programming
    Replies: 6
    Last Post: 29th April 2006, 13:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.