Results 1 to 3 of 3

Thread: Application crashing when setting QAbstractTableModel's parent to QListView

  1. #1
    Join Date
    May 2010
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Exclamation Application crashing when setting QAbstractTableModel's parent to QListView

    I have a QListView that I'm using my own subclass of QAbstractTableModel to drive, with the usual setModel() call. However, I would like to set my QAbstractTableView's parent to the QListView when I create the model, mainly so that the model is destroyed when the widget is.

    But this causes my program to crash with a EXC_BAD_ACCESS error (using QT 4.6 and Mac OS X 10.6 with XCode.) The stack trace points right back to my QAbstractTabelModel's initializer, which just passes the *parent parameter onto its own parent class.

    What's wrong? I'm fairly new to QT, so I may not be understanding something completely correctly.

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Application crashing when setting QAbstractTableModel's parent to QListView

    Can you post your code please?

  3. #3
    Join Date
    May 2010
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Application crashing when setting QAbstractTableModel's parent to QListView

    Aaaaand I've figured it out. It turns out that I was trying to parent the QAbstractDataModel to the QListView in my QMainWindow's initialization list. The problem was that, since I was using QT Designer, I had to call setupUi() to actually create all my widgets (my QMainWindow also subclassed the Ui::MyWindow class, which is why I could access the QListView at all.)

    Moving the creation of my QAbstractDataModel to right below setupUi now allows me to parent it correctly, without crashing.

    Thanks, asking for me code made me pare it down to just the essentials, which allowed me to see my problem!

Similar Threads

  1. Application crashing
    By addu in forum Qt Programming
    Replies: 9
    Last Post: 22nd May 2009, 10:37
  2. Application crashing on setting Model in QComboBox.
    By kaushal_gaurav in forum Qt Programming
    Replies: 6
    Last Post: 13th February 2009, 18:20
  3. application freezes without crashing (and closing)
    By nass in forum Qt Programming
    Replies: 15
    Last Post: 25th September 2007, 11:21
  4. Using QAbstractTableModel.parent
    By Max Yaffe in forum Newbie
    Replies: 7
    Last Post: 15th June 2007, 15:21
  5. Application is Crashing
    By shyam prasad in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2007, 17:04

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.