Qt World Summit: Submit your Presentation

Big problem with QStyle

  • Hi,

    Like in a topic - I read QStyle Doc and I don't know, which Param / function I have to use.

    I would like to get many information about QComboBox, but ( look at the picture ) not about the red rectangle element, but about green rectangle elements ( so I would like to get information about items in QComboBox's popup ).


    My questions:

    1. Where I can find a picture with a QWidget and his elements ( like popup, down-arrow, label )?
    2. How to know if that enums in QStyle are about red rectangle element or aboute green rectangle elements?
    3. How can I get size of indicator in item, which is in QComboBox's popup?

    Now I have:

        QStyleOptionComboBox opt;
        initStyleOption( &opt );
        QRect rect( style()->subElementRect( QStyle::SE_CheckBoxIndicator, &opt, this ) );

    But I don't know this is a good way. I use CheckBox enum, so is it ok?

    1. How to get size of "label" ( I don't know if is it a label ) in item in QCombobox's popup, where there is a item text?

    Now I have:

        QStyleOptionComboBox opt;
        QRect rect(style()->subElementRect(QStyle::SE_CheckBoxContents,&opt,this));

    The problem is the same as in second 2 question.

    1. Something like question 3. I would like to get size the same but without text margins. Look at the picture:


    I would like to get size without red rectangles ( text margins ).

    I try find something here too: https://code.woboq.org/qt5/qtbase/src/widgets/styles/qcommonstyle.cpp.html

    If you know for example only one answer - please write :) This is very important for me.

  • Lifetime Qt Champion

  • @jsulm Thank you, but this is good only for QStyleSheet. I would like the same for QStyle documentation.

Log in to reply