6.0.0-rc4Source

QStyleOptionViewItem Class

The QStyleOptionViewItem class describes how an item of an item view is drawn. More…

Header#include <QStyleOptionViewItem>
CMaketarget_link_libraries(app PRIVATE Nt::Widgets)
ModuleNt Widgets C++ Classes
InheritsQStyleOption

List of all members, including inherited members

Public Types

Public Functions

Public Variables

Detailed Description

A view fills one of these in for each item that it draws and passes it to its delegate; QStyledItemDelegate::initStyleOption() adds what the model says about the item: its text, check state, decoration, font and colors.

See also QStyledItemDelegate and QAbstractItemView.

Differences from Qt

The decoration is a QPixmap in decoration, where Qt has a QIcon in icon, as Nt has no QIcon. There is no viewItemPosition and no decorationPosition: the decoration is on the left.

Member Type Documentation

enum QStyleOptionViewItem::ViewItemFeature

What an item has and how it is drawn.

ConstantDescription
QStyleOptionViewItem::NoneNothing special.
QStyleOptionViewItem::WrapTextThe text may be broken into lines. Nt draws one line.
QStyleOptionViewItem::AlternateThe item is in a row that has the alternate background.
QStyleOptionViewItem::HasCheckIndicatorThe item has a check box.
QStyleOptionViewItem::HasDisplayThe item has text.
QStyleOptionViewItem::HasDecorationThe item has a decoration.

typedef QStyleOptionViewItem::ViewItemFeatures

The ViewItemFeatures type is a typedef for QFlags<ViewItemFeature>. It stores an OR combination of ViewItemFeature values.

Member Function Documentation

QStyleOptionViewItem::QStyleOptionViewItem()

Constructs an option for an item, with the type SO_ViewItem.

Member Variable Documentation

QBrush QStyleOptionViewItem::backgroundBrush

The background of the item, if the model gives it one.

Qt::CheckState QStyleOptionViewItem::checkState

The check state of the item, if it has a check box.

QPixmap QStyleOptionViewItem::decoration

The decoration of the item, drawn left of its text; null if it has none.

QSize QStyleOptionViewItem::decorationSize

The size that the decoration is drawn in; the size of decoration if it is empty.

Qt::Alignment QStyleOptionViewItem::displayAlignment

How the text is aligned in its part of the item; left and vertically centered by default.

ViewItemFeatures QStyleOptionViewItem::features

What the item has; see ViewItemFeature.

QFont QStyleOptionViewItem::font

The font of the text.

QModelIndex QStyleOptionViewItem::index

The model index of the item.

QLocale QStyleOptionViewItem::locale

The locale that numbers and dates are written with.

bool QStyleOptionViewItem::showDecorationSelected

Whether the decoration is part of what shows the selection.

QString QStyleOptionViewItem::text

The text of the item.

Qt::TextElideMode QStyleOptionViewItem::textElideMode

Where the text gets its ellipsis when it does not fit; at the end by default.

const QWidget * QStyleOptionViewItem::widget

The widget that the item is drawn on: the view, or nullptr.