QTableWidget won't sort cellwidgets!!!
Well I was coding some things, and I discovered that sorting doesn't work in Qt 4.3.0, for some reason I am doing something wrong, and I tried every method. But it seems that buttons disappear when you sort a widget even if sorting was disabled when adding items.
Does anyone have a solution or workaround for this? I tried adding just with i, or with qt->row(item) or with qt->row() but results haven't changed. I also notice, that it seems to only happen for rows 2,3 82 and 83. It's quite wierd.
Take a look and try this example code:
Code:
#include <QtGui>
int main(int argc, char *argv[])
{
qt->verticalHeader()->setVisible(false);
qt->setRowCount(85);
qt->setColumnCount(4);
qt->setSortingEnabled(false);
qt->setHorizontalHeaderItem(0, __colItem);
qt->setHorizontalHeaderItem(1, __colItem2);
qt->setHorizontalHeaderItem(2, __colItem3);
qt->setHorizontalHeaderItem(2, __colItem4);
for(int i = 0; i < 75; i++){
if(i < 10){
} else {
}
//if(isSortingEnabled()) ==== false!!!!
qt->setItem(i, 0, ax[i]);
qt->setItem(qt->row(ax[i]), 1, ax2[i]);
qt->setItem(qt->row(ax[i]), 2, ax3[i]);
qt->setItem(qt->row(ax[i]), 3, ax4[i]);
}
qt->setSortingEnabled(true);
//qt->sortItems(0, Qt::AscendingOrder);
qt->sortByColumn(0, Qt::AscendingOrder);
qt->show();
return app.exec();
}
Thank you for your help!
Re: QTableWidget won't sort cellwidgets!!!
Indeed, I reproduced your issue, and I found this on Trolltech's Task Tracker.
http://trolltech.com/developer/task-...ntry&id=166714
I'm currently looking at your code to see if there's something wrong ;-)
Re: QTableWidget won't sort cellwidgets!!!
Ok , seems it's messy when you implement everything in main..
I changed a little your code, just adding a subclass of QTableWidget, and now it works fine
EDIT : ooops, no, it doesn't work either...I remove the attachment...maybe you could provide this sample to Task Tracker, to me it seems like a bug.
Re: QTableWidget won't sort cellwidgets!!!
They seem to have rejected that bug, like as if it's not a bug, they tell me how to properly use it in the tracker, but then I guess they never tested their own code or were in a hurry.
Can someone send another tracker and update that?
Is there a more complex way like overriding the sort method, or perhaps looking into 4.3.1 source code, and seeing how they fixed it maybe???
Re: QTableWidget won't sort cellwidgets!!!
Well, I think you can repost, because I think your bug is different.
They precise in their report that you musn't enable table sorting while(or before) you add cell widgets...but in this case, you enable it only after items have been inserted...
That's why I think you can re-post...and refer to the previous bug that has been rejected !
Guilugi.
Re: QTableWidget won't sort cellwidgets!!!
I posted it, but I wish we can find some sort of easy work-around for it, maybe wysota or jpn knows how.
Re: QTableWidget won't sort cellwidgets!!!
I think they fixed it in 4.3.1, but I cant compile that crap. They dont allow you to compile it.
Re: QTableWidget won't sort cellwidgets!!!
I think patience may be the best right now : I don't know the actual state of 4.3.1, but it should come out as an official release soon enough :)