A widget cannot draw outside it's boundaries.
Since you rotate 90 degrees, you must also swap the width and height:
QSize s
= option.
rect.
size();
// rect has been initialized in QStyleOption::initFrom() s.transpose(); // swaps width and height
option.rect.setSize(s);
QSize s = option.rect.size(); // rect has been initialized in QStyleOption::initFrom()
s.transpose(); // swaps width and height
option.rect.setSize(s);
To copy to clipboard, switch view to plain text mode
..and you must translate the coordinate system to match rotation
p.rotate(-90);
p.translate(-height(), 0);
p.rotate(-90);
p.translate(-height(), 0);
To copy to clipboard, switch view to plain text mode
You might also want to take a look at QPushButtonPrivate::getStyleOption(). You need a properly initialized QStyleOptionButton to get the button drawn correctly.
Bookmarks