本文整理汇总了C++中QCheckBox::setIconSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QCheckBox::setIconSize方法的具体用法?C++ QCheckBox::setIconSize怎么用?C++ QCheckBox::setIconSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCheckBox
的用法示例。
在下文中一共展示了QCheckBox::setIconSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createIconButton
QAbstractButton* MainWindow::createIconButton(const QString &iconPath, const QString &text, QWidget *parent) const
{
QCheckBox *button = new QCheckBox(text, parent);
//button->setIcon(QIcon(iconPath));
button->setStyleSheet("QCheckBox::indicator { image: url(" + iconPath.arg("") + "); }"
"QCheckBox::indicator:hover { image: url(" + iconPath.arg("_hovered") + "); }"
"QCheckBox::indicator:pressed { image: url(" + iconPath.arg("_pressed") + "); }");
button->setIconSize(QImage(iconPath).size());
button->setContentsMargins(0, 0, 0, 0);
button->setCursor(Qt::PointingHandCursor);
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
return button;
}
示例2: loadIcons
///
/// \brief Widget::loadIcons
/// load all icons from items.json
void Widget::loadIcons() {
QFile file;
QString txt;
file.setFileName(":/resources/items.json");
file.open(QIODevice::ReadOnly | QIODevice::Text);
txt = file.readAll();
file.close();
// parse JSON
QJsonDocument doc = QJsonDocument::fromJson(txt.toUtf8());
QJsonObject obj = doc.object();
for (auto it = obj.begin(); it != obj.end(); ++it) {
QCheckBox* check = new QCheckBox();
check->setText((*it).toObject().value("complete_name").toString());
check->setIcon(QIcon((*it).toObject().value("icon").toString()));
check->setIconSize(QSize(50,50));
ui->gridLayout->addWidget(check);
}
}
示例3: processNewMin
void rareColorsDialog::processNewMin(int min) {
// clean out the old rows
for (int i = checkboxes_.size() - 1; i >= 0; --i) {
delete checkboxes_.takeAt(i);
}
// see sarcastic note about this krap at the bottom of this bleepin
// function
delete scrollWidget_; // deletes any children
scrollWidget_ = new QWidget(scroll_);
colorsLayout_ = new QVBoxLayout;
scrollWidget_->setLayout(colorsLayout_);
QList<QRgb> rareColors;
QList<QRgb> commonColors;
for (QHash<QRgb, int>::const_iterator it = colorCounts_.begin();
it != colorCounts_.end(); ++it) {
if (it.value() <= min) {
rareColors.push_back(it.key());
}
else {
commonColors.push_back(it.key());
}
}
// sort the rare colors by intensity
qSort(rareColors.begin(), rareColors.end(), qRgbIntensity());
if (!commonColors.isEmpty() && !rareColors.isEmpty()) {
// each row consists of a checkbox saying whether or not to include
// the row's color, followed by the rare color and its count and then
// the replacement color for the rare color
for (int i = 0, size = rareColors.size(); i < size; ++i) {
QRgb thisOldColor = rareColors[i];
// find the new color
QRgb thisNewColor = ::closestMatch(thisOldColor, commonColors);
const int thisColorCount = colorCounts_[thisOldColor];
const QString squareString = (thisColorCount == 1) ?
" square " : " squares ";
const QString iconString(::itoqs(thisColorCount) + squareString +
::colorToPrettyString(thisOldColor) + " --> " +
::colorToPrettyString(thisNewColor));
QCheckBox* checkBox = new QCheckBox(iconString);
const QPixmap iconPixmap = createIconPixmap(thisOldColor, thisNewColor);
checkBox->setIconSize(QSize(ICON_SIZE, ICON_SIZE));
checkBox->setIcon(QIcon(iconPixmap));
checkBox->setChecked(true);
checkboxes_.push_back(checkBox);
colorsLayout_->addWidget(checkBox);
}
}
else if (rareColors.isEmpty()) {
noRareColorsLabel_ =
new QLabel(tr("There aren't any colors that occur ") +
::itoqs(minCountBox_->value()) + " or fewer times!");
colorsLayout_->addWidget(noRareColorsLabel_);
}
else if (commonColors.isEmpty()) {
noReplacementColorsLabel_ =
new QLabel(tr("There are no replacement colors available!"));
colorsLayout_->addWidget(noReplacementColorsLabel_);
}
scrollWidget_->resize(colorsLayout_->sizeHint());
// if you put this up where the other stuff gets recreated (or you don't
// recreate the other stuff) then on the second and all later runs
// through this function colorsLayout_->sizeHint() will return (18, 18).
// Obviously.
scroll_->setWidget(scrollWidget_);
}