I'm trying a code to make a QPushButton
looking round , this code seems to be working, but after execution , it show me only the half of the ellipse, can anybody help me to figure out why is show only the half of it, its about the m_bouton1
?
I did before checked this link Change rectangular Qt button to round
But its not working , it appears only the half of it.
#include <QtWidgets>
#include "MyFenetre.h"
#include "MyWindow.h"
MyFenetre::MyFenetre() : QWidget()
{
setFixedSize(300, 150);
m_bouton = new QPushButton("Salut", this);
m_bouton->setFont(QFont("Comic Sans MS", 14));
m_bouton->move(110, 50);
m_bouton1=new QPushButton("Boutton RounD (*)");
m_bouton1->setFixedHeight(200);
m_bouton1->setFixedWidth(200);
QRect *rect = new QRect(0,0,190,190);
qDebug() << rect->size();
qDebug() << m_bouton1->size();
QRegion *region = new QRegion(*rect,QRegion::Ellipse);
qDebug() << region->boundingRect().size();
m_bouton1->setMask(*region);
QVBoxLayout *login_form= new QVBoxLayout;
login_form->addWidget(m_bouton);
login_form->addWidget(m_bouton1);
setLayout(login_form);
setWindowTitle("Button test");
//setWindowIcon(QIcon("icone.png"));
// Connexion du clic du bouton à la fermeture de l'application
QObject::connect(m_bouton, SIGNAL(clicked()), this, SLOT(changerFen()));
QObject::connect(m_bouton1, SIGNAL(clicked()), this, SLOT(changerFen()));
}
void MyFenetre::changerFen()
{
int f = 1;
emit askDisplayFen(f);
}