QT: I've inherited from QTreeView. I've inherited from QStandardItem. How do i Style the items?

Posted by San Jacinto on Stack Overflow See other posts from Stack Overflow or by San Jacinto
Published on 2010-04-09T18:53:18Z Indexed on 2010/04/10 3:53 UTC
Read the original article Hit count: 397

Filed under:
|
|
|

My Google skills must be failing me today.

I've inherited from QTreeView to create a TreeView that stores a QStandardItemModel instead of a QAbstractItemModel. I have also inherited from QStandardItem to create a class to store my data in an item as is necessary.

I've successfully inserted my derived QStandardItem into my derived QTreeView's QStandardItemModel. Now the trouble is, I can't figure out how to style it. I know that QTreeView has a setStyleSheet(QString) member, but I can't seem to get it working. It may be as simple as I'm not styling the correct attribute. Any pointers would be appreciated. Thanks.

For clarity, here are my class defs.

class SurveyTreeItem : public QStandardItem
{
public:
    SurveyTreeItem();
    SurveyTreeItem( const QString & text );
    ~SurveyTreeItem();
};

class StandardItemModelTreeView : public QTreeView
{
    public:

    StandardItemModelTreeView(QWidget* parent = 0);
    ~StandardItemModelTreeView();

    QStandardItemModel* getStandardItemModel();
};

I've tried the following StyleSheets:

StandardTreeView::Item
{
font: 87 12pt 'Arial Black';
}

StandardTreeView::QStandardItem
{
font: 87 12pt 'Arial Black';
}

QTreeView::QStandardItem
{
font: 87 12pt 'Arial Black';
}

QTreeView::Item
{
font: 87 12pt 'Arial Black';
}

QTreeView::SurveyTreeItem
{
font: 87 12pt 'Arial Black';
}

StandardTreeView::SurveyTreeItem
{
font: 87 12pt 'Arial Black';
}

© Stack Overflow or respective owner

Related posts about qt

Related posts about stylesheet