[Qt-interest] ***SPAM*** Delegate for QPixMap and Background Color

Ramesh ramesh.bs at robosoftin.com
Thu Apr 22 08:56:00 CEST 2010


Were are these ovveriden functions

QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index)
const;

	void paint(QPainter* painter, const QStyleOptionViewItem& option,
const QModelIndex& index)const;

you must get the width of the item from size hint..

paint operation must be done in paint.




-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of peter
Sent: Thursday, April 22, 2010 11:58 AM
To: qt-interest at trolltech.com
Subject: ***SPAM*** [Qt-interest] Delegate for QPixMap and Background Color

Hi,
I have some problems dealing with a delegate for QTableView, that
handles Qt::DecorationRole or Qt::TextColorRole,
I wrote some working delegates for converting some sql table stuff into
international Date, Time output and so on, but I cannot get the above
things to work...

Could anyone help here ?

Here is one of my classes:

Declaration:
class PB_DLLEXPORT PBTextTranslateDelegate : public QStyledItemDelegate
{
     Q_OBJECT
public:
     PBTextTranslateDelegate(QObject *parent, QStringList texte, QString
Fehler = Texte.Datenfehler);
     ~PBTextTranslateDelegate();

     QString displayText ( const QVariant & value, const QLocale &
locale ) const;
private:
     QStringList Text;
     QString Fehler;
};

Implementation:

PBTextTranslateDelegate::PBTextTranslateDelegate(QObject *parent,
QStringList liste, QString _Fehler)
:QStyledItemDelegate(parent)
{
     Text = liste;
     Fehler = _Fehler;
}

PBTextTranslateDelegate::~PBTextTranslateDelegate()
{
}

QString PBTextTranslateDelegate::displayText(const QVariant &value,
const QLocale &locale) const
{
     int offset = value.toInt();
     if ((offset >= 0) && (offset < Text.count()))
         return Text.at(offset);
     return Fehler;
}

Actually I solve this with a overwritten model class from i.e.
QSqlQueryModel or a self written Models for some data structures, but
for the standard case, it is better to use a delegate for a column...

Regards,
Peter
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


-----------------------------------------------
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus.



More information about the Qt-interest-old mailing list