I've this code:

Qt Code:
  1. #include <QApplication>
  2. #include <QPushButton>
  3.  
  4. int main(int argc, char **argv) {
  5. QApplication a(argc, argv);
  6. QWidget *widget = new QWidget();
  7. widget->setFixedWidth(600);
  8. widget->setFixedHeight(600);
  9. QPushButton* button = new QPushButton(widget);
  10. button->setText("Test");
  11. button->setStyleSheet("QPushButton { background: red; width: 400px; height: 200px; }");
  12. int w = button->width();
  13. int h = button->height();
  14.  
  15. QObject::connect(button, &QPushButton::clicked, button, [=]() { button->setText("W: " + QString::number(w) + " H: " + QString::number(h)); });
  16.  
  17. widget->show();
  18. return a.exec();
  19. }
To copy to clipboard, switch view to plain text mode 

The button is shown correctly (color is red and dimensions are right), but `w` and `h` variables are `100` and `30`, respectively. It seems that `width()` and `height()` does not take the updated values after applying the stylesheet.
How can I retrieve dimensions of a `QPushButton` correctly after applying a stylesheet?


I'm using Qt 5.11.0 on Visual Studio 2017 (64 bit).