Results 1 to 5 of 5

Thread: QTableWidget click in empty space results in error?

  1. #1
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QTableWidget click in empty space results in error?

    Hi all,

    I need a hint!

    I've connected a signal like this:
    connect(personeelTableWidget, SIGNAL(cellClicked(int, int)), this, SLOT(clickOntvangen(int, int)));

    to a QTableWidget ( personeelTableWidget ) the table widget has 4 filled rows and a lot of open space. When I click in the empty space nothing happens (that is de slot "clickOntvangen" is not called. I think thats correct!.
    When I click one off the cells in the table widget the slot "clickOntvangen" gets called, just as expected!. But when I click in the empty space, after a valid selection of a cell, the application terminates with the following message:


    ASSERT failure in QList<T>:perator[]: "index out of range", file /usr/local/Trolltech/Qt-4.1.0/include/QtCore/qlist.h line 369

    Can somebody give me a hint how to avoid this kind of behavior because I don't like it?

    regards,

    Giel
    P.S. in the preview there's a smilie on the wrong place, could not delete it! ( it is not in the original message

  2. #2
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget click in empty space results in error?

    Quote Originally Posted by Giel Peters
    Qt Code:
    1. ASSERT failure in QList<T>::operator[]: "index out of range", file /usr/local/Trolltech/Qt-4.1.0/include/QtCore/qlist.h line 369
    To copy to clipboard, switch view to plain text mode 
    I don't think that the problem is in your connection, could you please elaborete more on your code?
    Quote Originally Posted by Giel Peters
    P.S. in the preview there's a smilie on the wrong place, could not delete it! ( it is not in the original message
    Use the [C O D E] tags to avoid it, see below

    AClass:rivateMember(funnyLooking);
    Qt Code:
    1. AClass::privateMember(notFunnyLooking);
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: QTableWidget click in empty space results in error?

    Quote Originally Posted by yop
    Use the [C O D E] tags to avoid it
    You can also select "Disable smilies in text" from "Additional Options" section below the editor.

  4. #4
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget click in empty space results in error?

    Yop,

    that was the hint I needed!

    there was one more connection i made in my connection routine:
    void Personeel::connectSignals()
    {
    connect(personeelTableWidget, SIGNAL(cellClicked(int, int)), this, SLOT(clickOntvangen(int, int)));
    connect(personeelTableWidget, SIGNAL(itemSelectionChanged()), this, SLOT(selectieOntvangen()));
    }

    The second connection was made to the following slot:

    void Personeel::selectieOntvangen( )
    {
    QList<QTableWidgetSelectionRange> dezeSelectie;// = new QTableWidgetSelectionRange();
    dezeSelectie = personeelTableWidget->selectedRanges();
    if( dezeSelectie[0].rowCount() == 1 && dezeSelectie[0].columnCount() == personeelTableWidget->columnCount() )
    {
    personeelTableWidget->insertRow( 1 );
    }
    }

    This routine called the ASSERT.

    I changed it to this:

    void Personeel::selectieOntvangen( )
    {
    QList<QTableWidgetSelectionRange> dezeSelectie;// = new QTableWidgetSelectionRange();
    dezeSelectie = personeelTableWidget->selectedRanges();
    if(dezeSelectie.count() != 0)
    {
    if( dezeSelectie[0].rowCount() == 1 && dezeSelectie[0].columnCount() == personeelTableWidget->columnCount() )
    {
    personeelTableWidget->insertRow( 1 );
    }
    }
    }

    and the problem was solved!
    When clicked in empty space when there is a selection made of one or more cells the QList holds nothing, I did not test for "nothing" in my early routine

    In dutch: "I did not look further then my nose was long!"

    thanks for the hint,

    regards,
    Giel Peters

  5. #5
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget click in empty space results in error?

    Wow my eyes hurt when I read your code Is it Dutch? Maybe I should put some greek in your code with latin characters (we call them greeglish) to see who hurts the other the most .
    Anyway besides fun, I didn't do much I just pointed you away from the wrong direction. I'm glad it was enough

Similar Threads

  1. nmake error during .pro compiling
    By mattia in forum Installation and Deployment
    Replies: 5
    Last Post: 18th June 2008, 11:15
  2. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 14:43
  3. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 03:49
  4. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 13:19
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 13:52

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.