It will be invisible, but this is because you do not have an ellipse centered around the right point.
QWidget :: setMask "causes only parts of the widget that overlap the region to be visible. If pixels outside the widget's rectangle () are included in the region, window system controls in this region may or may not be displayed depending on the platform."
Try using this code and you will see:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->pushButton->setText("Test Text"); ui->pushButton->setFixedHeight(200); ui->pushButton->setFixedWidth(200); QRect *rect = new QRect(0,0,190,190); qDebug() << rect->size(); qDebug() << ui->pushButton->size(); QRegion* region = new QRegion(*rect,QRegion::Ellipse); qDebug() << region->boundingRect().size(); ui->pushButton->setMask(*region); }
Ps. Why do you set pushButton height twice? I assume the typo and you meant the width.
stackunderflow
source share