Results 1 to 3 of 3

Thread: Segmentation fault in QListViewItem

  1. #1
    Join Date
    Sep 2006
    Location
    Rio de Janeiro, Brazil
    Posts
    44
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Segmentation fault in QListViewItem

    Hi friends,

    I am using the QListView to list given of the data base. The clic problem is when I in the white part of the screen where an item does not exist, of the error:

    "Segmentation fault (core dumped)"

    and the closed application and.

    QSqlQuery queryViatura( QUERY_LISTVIATURES ); /* Query Sql */

    lstViewViaturaDisponivel->clear();
    while(queryViatura.next())
    {
    lstViewViaturaDisponivel->setColumnWidthMode( 0, QListView::Maximum );
    lstViewViaturaDisponivel->adjustColumn( 0 );
    lstViewViaturaDisponivel->setColumnWidth( 0, 140 );
    lstViewViaturaDisponivel->setColumnWidth( 1, 300 );
    lstViewViaturaDisponivel->setColumnWidth( 2, 200 );
    lstViewViaturaDisponivel->insertItem( new QListViewItem( lstViewViaturaDisponivel,
    queryViatura.value( 0 ).toString(),
    queryViatura.value( 1 ).toString(),
    queryViatura.value( 2 ).toString()
    ));
    }

    QObject::connect(lstViewViaturaDisponivel, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( selectViewItemViaturasEmpenha( QListViewItem *) ) );

    void ViaturaDisponivelForm::selectViewItemViaturasEmpen ha( QListViewItem *item )
    {
    globalVtrEmpenha = item->text(0);

    cout << "E-193 ==> ListViewViaturaEmpenha item selecionado " << globalVtrEmpenha << endl;

    }

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Segmentation fault in QListViewItem

    void QListView::clicked ( QListViewItem * item ) [signal]
    This signal is emitted whenever the user clicks (mouse pressed and mouse released) in the list view. item is the clicked list view item, or 0 if the user didn't click on an item.
    Check whther item isn't null before you use it.

  3. #3
    Join Date
    Sep 2006
    Location
    Rio de Janeiro, Brazil
    Posts
    44
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Wink Re: Segmentation fault in QListViewItem

    Yes, now it is working,

    void ViaturaDisponivelForm::selectViewItemViaturasEmpen ha( QListViewItem *item )
    {

    if(!item)
    {
    globalVtrEmpenha = QString::null;
    } else {

    globalVtrEmpenha = item->text(0);

    } }

Similar Threads

  1. segmentation fault insert QString in QCombobox
    By regix in forum Qt Programming
    Replies: 16
    Last Post: 8th August 2006, 08:46
  2. why does qt program meet segmentation fault?
    By wquanw in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 15th May 2006, 16:52
  3. Replies: 2
    Last Post: 25th March 2006, 06:54
  4. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 16:30
  5. [qmake_image_collection.cpp] Segmentation fault
    By CrazyLegz in forum KDE Forum
    Replies: 1
    Last Post: 4th February 2006, 11:43

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.