For my Qt Dialog Window, I am trying to create a checkbox that is centered, but is always checked and uncheckable. I did this by combining
ui->baseBox->setStyleSheet("margin-left:50%; margin-right:50%;");
and
ui->baseBox->setAttribute(Qt::WA_TransparentForMouseEvents);
ui->baseBox->setFocusPolicy(Qt::NoFocus);
However, I can only do the first bit of code or the second. When I run the both of them together, my checkBox baseBox completely disappears from the GUI.
So I tried doing :
ui->baseBox->setAttribute(Qt::WA_TransparentForMouseEvents);
ui->baseBox->setFocusPolicy(Qt::NoFocus);
ui->baseBox->setStyleSheet(ui->baseBox->styleSheet().append(QString("margin-left:50%; margin-right:50%;")));
based on How to add style via setStyleSheet() without losing orignal style in Qt?
However, I am running into the same problem.
How can I do both of these things ? Why is my check box disappearing ?