Results 1 to 3 of 3

Thread: QComboBox crashes my application

  1. #1
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QComboBox crashes my application

    Hi,

    I have a little bit of trouble with my application crashing while filling a combo box.

    Qt Code:
    1. gameLabel = new QLabel(tr("Spielname:"));
    2. gameCombo = new QComboBox();
    3.  
    4. connect(gameCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(loadGameInfo(int)));
    5.  
    6.  
    7. games->setTable("games");
    8. games->setSort(1, Qt::AscendingOrder);
    9. games->select();
    10.  
    11. qDebug() << "LoadGameDialog: Row Count";
    12. qDebug() << games->rowCount();
    13.  
    14. for (int i = 0; i < games->rowCount(); ++i) {
    15.  
    16. QSqlRecord r = games->record(i);
    17.  
    18. qDebug() << "LoadGameDialog: name ";
    19. qDebug() << r.value("name").toString();
    20. qDebug() << "LoadGameDialog: id_games";
    21. qDebug() << r.value("id_games");
    22.  
    23. gameCombo->addItem(r.value("name").toString(), r.value("id_games"));
    24.  
    25. qDebug() << "Item added to combo box";
    26.  
    27. }
    To copy to clipboard, switch view to plain text mode 

    I'm not even sure if the addItem() function is the problem since it worked fine till now. But the commandline output lead me to the conclusion that the crash is caused by the addItem() function.

    Here is the Console

    Qt Code:
    1. Starte E:\Workspace\MASA\trunk\MASA-build-desktop\debug\MASA.exe...
    2. [Main] Cannot load translation file
    3. [DbConnection] DB Connection "qt_sql_default_connection" established
    4. Enter MainWindow::loadGame
    5. before new dialog
    6. LoadGameDialog: Row Count
    7. 72
    8. LoadGameDialog: name
    9. "20120207-TestKameraeinstellungUSZ"
    10. LoadGameDialog: id_games
    11. QVariant(int, 73)
    12. E:\Workspace\MASA\trunk\MASA-build-desktop\debug\MASA.exe beendet, Rückgabewert -1073741819
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QComboBox crashes my application

    That is not how you normally debug. See the backtrace to identify what really crashes the application. I bet it is not the addItem! What is it: You have a connect statement before you fill the box, thus the connection is established after you add a item, so loadGameInfo() is called. Look there for the crash!

  3. #3
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QComboBox crashes my application

    Thx for the info, it seemed really wired to me that this function would crash. Unfortunatly my debugger is not working atm, I have some issues with other librarys not beeing built with the same compiler. Hope to fix that soon. Anyways thx for the hint.

Similar Threads

  1. QT application crashes.
    By coding_neo in forum Qt Programming
    Replies: 3
    Last Post: 24th October 2011, 13:30
  2. Application crashes when it has a particular name
    By hunsrus in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2010, 20:50
  3. Application crashes
    By waynew in forum Newbie
    Replies: 1
    Last Post: 2nd November 2009, 10:31
  4. QtStyles and Application Crashes
    By vladozar in forum Qt Programming
    Replies: 0
    Last Post: 19th September 2009, 14:59
  5. My application crashes
    By sophister in forum Qt Programming
    Replies: 13
    Last Post: 27th April 2009, 07:39

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.