PDA

View Full Version : Application Crash problem on second time click on Menu Arrow of QToolButton



johnMick
8th August 2011, 11:40
Hi,
In my APPlication I have to show filter option (as filter option in xls)in Qtable widget for this
I have used tool Button( with property "QToolButton::MenuButtonPopup") to display Menu List and
Upon First Click upon Menu arrow it should show Menu list and selection of any of the Menu it should show only row having the text.
This functionality works fine.
But if Nothing is selected from Menu list and user has clicked Menu arrow second time then list should be hidden but in my case
application crashes giving error:

ASSERT failure in QList<T>::operator[]: "index out of range", file ..\..\..\..\Qt\2010.04\qt\include/QtCore/../../src/corelib/tools/qlist.h, line 447


I have written below code:

QToolButton *lToolButton = new QToolButton();
lToolButton->setPopupMode(QToolButton::MenuButtonPopup);
lToolButton->setAutoRaise(true);
lToolButton->setText("Filter");
QMenu *lMenu = new QMenu();
QAction *lAction = new QAction("All",this);
lMenu->addAction(lAction);
lToolButton->setMenu(lMenu);


Please let me know what is wrong in my coding.

Dong Back Kim
9th August 2011, 02:48
Obviously, this is a out of range assertion failure so it means you are accessing an item in a list with invalid index. Since you are saying "if Nothing is selected from Menu list", it means there is no such list at all so it sounds like you are trying to access a index of null object? Are you sure the error is from the codes you provided because I can't think of any index out of range failures from the codes. I might be wrong... =(

Regards,