Ahi, my custom items seem to be ignored...
Here is some code:
CTableWidgetItem.h
#include <QtGui>
/** Subclass definition **/
{
public:
CTableWidgetItem();
bool operator<(const CTableWidgetItem &item);
};
#include <QtGui>
/** Subclass definition **/
class CTableWidgetItem: public QTableWidgetItem
{
public:
CTableWidgetItem();
bool operator<(const CTableWidgetItem &item);
};
To copy to clipboard, switch view to plain text mode
CTableWidgetItem.cpp
#include "CTableWidgetItem.h"
CTableWidgetItem::CTableWidgetItem()
{
}
bool CTableWidgetItem::operator<(const CTableWidgetItem &item)
{
if(text().toUpper()<item.text().toUpper())
return true;
else
return false;
}
#include "CTableWidgetItem.h"
CTableWidgetItem::CTableWidgetItem()
{
}
bool CTableWidgetItem::operator<(const CTableWidgetItem &item)
{
if(text().toUpper()<item.text().toUpper())
return true;
else
return false;
}
To copy to clipboard, switch view to plain text mode
then I used my CTableWidgetItem instead of QTableWidgetItem in the table, like this:
int row=0;
...
CTableWidgetItem *idvar=new CTableWidgetItem;
idvar->setText(id);
ui.tbwvariations->setItem(row,0,idvar); //tbwvariations is a GUI QTableWidget
QString id;
int row=0;
...
CTableWidgetItem *idvar=new CTableWidgetItem;
idvar->setText(id);
ui.tbwvariations->setItem(row,0,idvar); //tbwvariations is a GUI QTableWidget
To copy to clipboard, switch view to plain text mode
when I click the table's headbar they get sorted case insensitive like always.
I tried a MessageBox in the operator method, but it get no ever called, so application never passes through it.
What is the mistake...?
Bookmarks