0
私はqt5-creatorデザイナーとiamを使って、フレーム内のQPushButtonsをカスタマイズしています。 私はこれを試しましたが、これは試してみました。私qt5でCSSの要素のジオメトリを設定する方法
.col-1-row-2 { position: fixed; top: 500 px; left: 500 px; }
のために私はabsolute
とrelative
でfixed
を交換したが、何も変わっていません。 CSSクラスの各要素のデフォルトジオメトリを設定または変更するにはどうすればよいですか? とフレームのジオメトリ?
iは
* {
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 CSSがいずれかの作業をしないプロジェクト
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();
}
QSSファイルにCSSを適用するには、この関数を使用します。