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?

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.