返回介绍

QStyleOption Class

发布于 2019-10-04 15:03:10 字数 6550 浏览 960 评论 0 收藏 0

The QStyleOption class specifies optional parameters for QStyle functions. More...

#include <qstyle.h>

List of all member functions.

Public Members

  • enum StyleOptionDefault { Default }
  • QStyleOption ( StyleOptionDefault = Default )
  • QStyleOption ( intin1, intin2 )
  • QStyleOption ( intin1, intin2, intin3, intin4 )
  • QStyleOption ( QMenuItem*m )
  • QStyleOption ( QMenuItem*m, intin1 )
  • QStyleOption ( QMenuItem*m, intin1, intin2 )
  • QStyleOption ( constQColor&c )
  • QStyleOption ( QTab*t )
  • QStyleOption ( QListViewItem*i )
  • QStyleOption ( Qt::ArrowTypea )
  • bool isDefault () const
  • int lineWidth () const
  • int midLineWidth () const
  • int frameShape () const
  • int frameShadow () const
  • QMenuItem * menuItem () const
  • int maxIconWidth () const
  • int tabWidth () const
  • const QColor & color () const
  • QTab * tab () const
  • QListViewItem * listViewItem () const
  • Qt::ArrowType arrowType () const

Detailed Description

The QStyleOption class specifies optional parameters for QStyle functions.

Some QStyle functions take an optional argument specifying extra information that is required for a paritical primitive or control. So that the QStyle class can be extended, QStyleOption is used to provide a variable-argument for these options.

The QStyleOption class has constructors for each type of optional argument, and this set of constructors may be extended in future Qt releases. There are also corresponding access functions that return the optional arguments: these too may be extended.

For each constructor, you should refer to the documentation of the QStyle functions to see the meaning of the arguments.

When calling QStyle functions from your own widgets, you must only pass either the default QStyleOption or the argument that QStyle is documented to accept. For example, if the function expects QStyleOption(QMenuItem *, int), passing QStyleOption(QMenuItem *) leaves the optional integer argument uninitialized.

When subclassing QStyle, you must similarly only expect the default or documented arguments. The other arguments will have uninitialized values.

If you make your own QStyle subclasses and your own widgets, you can make a subclass of QStyleOption to pass additional arguments to your QStyle subclass. You will need to cast the "const QStyleOption&" argument to your subclass, so be sure your style has been called from your widget.

See also Widget Appearance and Style.


Member Type Documentation

QStyleOption::StyleOptionDefault

This enum value can be passed as the optional argument to any QStyle function.

  • QStyleOption::Default

Member Function Documentation

QStyleOption::QStyleOption ( StyleOptionDefault = Default )

The default option. This can always be passed as the optional argument to QStyle functions.

QStyleOption::QStyleOption ( intin1, intin2 )

Pass two integers, in1 and in2. For example, linewidth and midlinewidth.

QStyleOption::QStyleOption ( intin1, intin2, intin3, intin4 )

Pass four integers, in1, in2, in3 and in4.

QStyleOption::QStyleOption ( QMenuItem*m )

Pass a menu item, m.

QStyleOption::QStyleOption ( QMenuItem*m, intin1 )

Pass a menu item and an integer, m and in1.

QStyleOption::QStyleOption ( QMenuItem*m, intin1, intin2 )

Pass a menu item and two integers, m, in1 and in2.

QStyleOption::QStyleOption ( constQColor&c )

Pass a color, c.

QStyleOption::QStyleOption ( QTab*t )

Pass a QTab, t.

QStyleOption::QStyleOption ( QListViewItem*i )

Pass a QListViewItem, i.

QStyleOption::QStyleOption ( Qt::ArrowTypea )

Pass an Qt::ArrowType, a.

Qt::ArrowType QStyleOption::arrowType () const

Returns an arrow type if the appropriate constructor was called; otherwise the return value is undefined.

constQColor& QStyleOption::color () const

Returns a color if the appropriate constructor was called; otherwise the return value is undefined.

int QStyleOption::frameShadow () const

Returns a QFrame::Shadow value if the appropriate constructor was called; otherwise the return value is undefined.

int QStyleOption::frameShape () const

Returns a QFrame::Shape value if the appropriate constructor was called; otherwise the return value is undefined.

bool QStyleOption::isDefault () const

Returns TRUE if the option was constructed with the default constructor; otherwise returns FALSE.

int QStyleOption::lineWidth () const

Returns the line width if the appropriate constructor was called; otherwise the return value is undefined.

QListViewItem* QStyleOption::listViewItem () const

Returns a QListView item if the appropriate constructor was called; otherwise the return value is undefined.

int QStyleOption::maxIconWidth () const

Returns the maximum width of the menu item check area if the appropriate constructor was called; otherwise the return value is undefined.

QMenuItem * QStyleOption::menuItem () const

Returns a menu item if the appropriate constructor was called; otherwise the return value is undefined.

int QStyleOption::midLineWidth () const

Returns the mid-line width if the appropriate constructor was called; otherwise the return value is undefined.

QTab* QStyleOption::tab () const

Returns a QTabBar tab if the appropriate constructor was called; otherwise the return value is undefined.

int QStyleOption::tabWidth () const

Returns the tab indent width if the appropriate constructor was called; otherwise the return value is undefined.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文