Hi everyone.
I've managed to compile a program that uses a subclass to QTableWidgetItem, but there are still some issues that needs to be sorted out.
First here is the code
{
public:
QInt64Item(qint64 data=0);
bool operator< ( const QInt64Item& other ) const;
protected:
qint64 m_data;
};
class QInt64Item : public QTableWidgetItem
{
public:
QInt64Item(qint64 data=0);
QVariant data(int role) const;
bool operator< ( const QInt64Item& other ) const;
protected:
qint64 m_data;
};
To copy to clipboard, switch view to plain text mode
And here is the rest of the code
#include "qint64item.h"
QInt64Item::QInt64Item(qint64 data)
{
m_data = data;
this->setFlags(Qt::NoItemFlags);
this->setFlags(Qt::ItemIsEnabled);
this->setSelected(false);
}
QVariant QInt64Item
::data(int role
) const {
if (role==Qt::EditRole)
return m_data;
else
}
bool QInt64Item::operator< ( const QInt64Item& other ) const
{
return m_data < other.m_data;
}
#include "qint64item.h"
QInt64Item::QInt64Item(qint64 data)
{
m_data = data;
this->setFlags(Qt::NoItemFlags);
this->setFlags(Qt::ItemIsEnabled);
this->setSelected(false);
}
QVariant QInt64Item::data(int role) const
{
if (role==Qt::EditRole)
return m_data;
else
return QString::number(m_data);
}
bool QInt64Item::operator< ( const QInt64Item& other ) const
{
return m_data < other.m_data;
}
To copy to clipboard, switch view to plain text mode
And here I use it
QInt64Item* new64Item;
new64Item = new QInt64Item(my_int64_variable);
new64Item
->setForeground
(QBrush(Qt
::black));
m_ui->MyTable->setItem(row, 0, new64Item);
QInt64Item* new64Item;
new64Item = new QInt64Item(my_int64_variable);
new64Item->setForeground(QBrush(Qt::black));
m_ui->MyTable->setItem(row, 0, new64Item);
To copy to clipboard, switch view to plain text mode
I've attached what it lookslike (dump.jpeg) but I should add that I want all text to be aligned to the right, no checkboxes, and sorting does not sort numerically when clicking in the header.
So I'm very grateful for any hints on this issue
Bookmarks