Qt World Summit: Register Today!

QStyledItemDelegate subclass for drawing QSlider behaves strangely on macOS

  • I wrote a subclass of QStyledItemDelegate to paint a QSlider inside a QAbstractTableView.

    On Windows this behaves just fine. But on macOS every single delegate is being painted in the top left corner of the table view. I tried with several Qt versions (5.9.6, 5.12.0) , they all behave the same.

    Please see this example project: https://github.com/tobireuen/sliderdelegate-test.git
    In sliderdelegate.cpp:45 I assign the option.rect to my instance of QStyleOptionSlider. The coordinates of this rect are fine on both Windows and macOS. This can be seen in the debug prints.

    Where does this difference come from? How can I get rid of the problem on macOS? Am I doing something wrong regarding the configuration of QStyleOptionSlider?

    Thanks you for any help

  • Lifetime Qt Champion


    No, you're doing things correctly. It's a bug in the macOS style. You should check the bug report system to see if it's something known. If not, please open a new report providing your project as a zip file in the report.

    In any, don't forget to post the link to the report here.

  • Hi SGaist,

    thanks for pointing this out. I found this bug report regarding the issue: https://bugreports.qt.io/browse/QTBUG-72558

    I can help myself using the fusion style for now. But let's hope this gets fixed soon.

  • Lifetime Qt Champion

    The problem is similar yet it's not the same control that has the issue. You should open a new report and link it to this one.

  • Just a quick update:
    I did as you told, the report got closed as a duplicate just an hour later. Well, well.

Log in to reply