J'utilise qt5-creator designer et iam en utilisant css pour personnaliser QPushButtons dans un cadre Je veux définir la géométrie des boutons avec css J'ai essayé mais cela ne fonctionne pas pour moicomment définir la géométrie d'un élément en css en qt5
.col-1-row-2 { position: fixed; top: 500 px; left: 500 px; }
i remplacé fixed
avec absolute
et relative
mais rien n'a changé. comment puis-je définir ou modifier la géométrie par défaut de chaque élément de sa classe css? et la géométrie des cadres?
i utiliser cette fonction pour appliquer le projet css au
void MainWindow::loadCss()
{
int rows = 7, mrows = 4;
int btnWidth = width()/5,
btnHeight = height()/(rows + 1);
QString css = "", temp = ".col-%1-row-%2 { top: %3 px; %4: %5 px; }";
for (int i = 1 ; i <= mrows ; ++i)
{
css += temp.arg(1).arg(i).arg((rows - mrows + i - 1) * btnHeight).arg("left").arg(40);
css += temp.arg(2).arg(i).arg((rows - mrows + i - 1) * btnHeight).arg("right").arg(40);
}
QFile file(":/css.qss");
file.open(QFile::ReadOnly);
qApp->setStyleSheet(QString::fromLatin1(file.readAll())
.replace("${fullWidth}", QString::number(width()))
.replace("${fullHeight}", QString::number(height()))
.replace("${btnHeight}", QString::number(btnHeight))
.replace("${btnWidth}", QString::number(btnWidth))
+ css
);
file.close();
}
de fichier qss
* {
font-size: 40px;
/* qproperty-alignment: AlignCenter; */
background-color: none;
}
QFrame {
position: fixed;
top: 0;
left: 0;
min-width: ${fullWidth} px;
min-height: ${fullHeight} px;
max-width: ${fullWidth} px;
max-height: ${fullHeight} px;
}
QPushButton {
min-width: ${btnWidth} px;
min-height: ${btnHeight} px;
}
#MainWindow {
border-image: url(:/images/sky.jpg) 0 0 0 0 stretch stretch;
border-width: 0px;
}
QFrame ne travaille css non plus.