本文整理汇总了C++中QCheckBox::height方法的典型用法代码示例。如果您正苦于以下问题:C++ QCheckBox::height方法的具体用法?C++ QCheckBox::height怎么用?C++ QCheckBox::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCheckBox
的用法示例。
在下文中一共展示了QCheckBox::height方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void StartDlg::init(QStringList partsName)
{
FlowLayout *layout = new FlowLayout(ui->groupBox);
for(int i=0;i<partsName.count();i++)
{
QCheckBox *check = new QCheckBox(partsName.at(i),ui->groupBox);
check->setChecked(true);
check->setMinimumSize(QSize(100, check->height()));
layout->addWidget(check);
checkList.append(check);
}
adjustSize();
ui->groupBox->setLayout(layout);
}
示例2: updateItemWidgets
void ServiceItemDelegate::updateItemWidgets(const QList<QWidget*> widgets,
const QStyleOptionViewItem& option,
const QPersistentModelIndex& index) const
{
QCheckBox* checkBox = static_cast<QCheckBox*>(widgets[0]);
KPushButton *configureButton = static_cast<KPushButton*>(widgets[1]);
const int itemHeight = sizeHint(option, index).height();
// Update the checkbox showing the service name and icon
const QAbstractItemModel* model = index.model();
checkBox->setText(model->data(index).toString());
const QString iconName = model->data(index, Qt::DecorationRole).toString();
if (!iconName.isEmpty()) {
checkBox->setIcon(KIcon(iconName));
}
checkBox->setChecked(model->data(index, Qt::CheckStateRole).toBool());
const bool configurable = model->data(index, ServiceModel::ConfigurableRole).toBool();
int checkBoxWidth = option.rect.width();
if (configurable) {
checkBoxWidth -= configureButton->sizeHint().width();
}
checkBox->resize(checkBoxWidth, checkBox->sizeHint().height());
checkBox->move(0, (itemHeight - checkBox->height()) / 2);
// Update the configuration button
if (configurable) {
configureButton->setEnabled(checkBox->isChecked());
configureButton->setIcon(KIcon("configure"));
configureButton->resize(configureButton->sizeHint());
configureButton->move(option.rect.right() - configureButton->width(),
(itemHeight - configureButton->height()) / 2);
}
configureButton->setVisible(configurable);
}
示例3: updateItemWidgets
void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const
{
// draws:
// AccountName
// Checkbox | Icon | | ConnectionIcon | ConnectionState
// errorMessage
if (!index.isValid()) {
return;
}
Q_ASSERT(widgets.size() == 6);
// Get the widgets
QCheckBox* checkbox = qobject_cast<QCheckBox*>(widgets.at(0));
ChangeIconButton* changeIconButton = qobject_cast<ChangeIconButton*>(widgets.at(1));
QLabel *statusTextLabel = qobject_cast<QLabel*>(widgets.at(2));
QLabel *statusIconLabel = qobject_cast<QLabel*>(widgets.at(3));
EditDisplayNameButton *displayNameButton = qobject_cast<EditDisplayNameButton*>(widgets.at(4));
QLabel *connectionErrorLabel = qobject_cast<QLabel*>(widgets.at(5));
Q_ASSERT(checkbox);
Q_ASSERT(changeIconButton);
Q_ASSERT(statusTextLabel);
Q_ASSERT(statusIconLabel);
Q_ASSERT(displayNameButton);
Q_ASSERT(connectionErrorLabel);
bool isSelected(itemView()->selectionModel()->isSelected(index) && itemView()->hasFocus());
bool isEnabled(index.data(KTp::AccountsListModel::EnabledRole).toBool());
KIcon accountIcon(index.data(Qt::DecorationRole).value<QIcon>());
KIcon statusIcon(index.data(KTp::AccountsListModel::ConnectionStateIconRole).value<QIcon>());
QString statusText(index.data(KTp::AccountsListModel::ConnectionStateDisplayRole).toString());
QString displayName(index.data(Qt::DisplayRole).toString());
QString connectionError(index.data(KTp::AccountsListModel::ConnectionErrorMessageDisplayRole).toString());
Tp::AccountPtr account(index.data(KTp::AccountsListModel::AccountRole).value<Tp::AccountPtr>());
if (!account->isEnabled()) {
connectionError = i18n("Click checkbox to enable");
}
QRect outerRect(0, 0, option.rect.width(), option.rect.height());
QRect contentRect = outerRect.adjusted(m_hpadding,m_vpadding,-m_hpadding,-m_vpadding); //add some padding
// checkbox
if (isEnabled) {
checkbox->setChecked(true);;
checkbox->setToolTip(i18n("Disable account"));
} else {
checkbox->setChecked(false);
checkbox->setToolTip(i18n("Enable account"));
}
int checkboxLeftMargin = contentRect.left();
int checkboxTopMargin = (outerRect.height() - checkbox->height()) / 2;
checkbox->move(checkboxLeftMargin, checkboxTopMargin);
// changeIconButton
changeIconButton->setIcon(accountIcon);
changeIconButton->setAccount(account);
// At the moment (KDE 4.8.1) decorationSize is not passed from KWidgetItemDelegate
// through the QStyleOptionViewItem, therefore we leave default size unless
// the user has a more recent version.
if (option.decorationSize.width() > -1) {
changeIconButton->setButtonIconSize(option.decorationSize.width());
}
int changeIconButtonLeftMargin = checkboxLeftMargin + checkbox->width();
int changeIconButtonTopMargin = (outerRect.height() - changeIconButton->height()) / 2;
changeIconButton->move(changeIconButtonLeftMargin, changeIconButtonTopMargin);
// statusTextLabel
QFont statusTextFont = option.font;
QPalette statusTextLabelPalette = option.palette;
if (isEnabled) {
statusTextLabel->setEnabled(true);
statusTextFont.setItalic(false);
} else {
statusTextLabel->setDisabled(true);
statusTextFont.setItalic(true);
}
if (isSelected) {
statusTextLabelPalette.setColor(QPalette::Text, statusTextLabelPalette.color(QPalette::Active, QPalette::HighlightedText));
}
statusTextLabel->setPalette(statusTextLabelPalette);
statusTextLabel->setFont(statusTextFont);
statusTextLabel->setText(statusText);
statusTextLabel->setFixedSize(statusTextLabel->fontMetrics().boundingRect(statusText).width(),
statusTextLabel->height());
int statusTextLabelLeftMargin = contentRect.right() - statusTextLabel->width();
int statusTextLabelTopMargin = (outerRect.height() - statusTextLabel->height()) / 2;
statusTextLabel->move(statusTextLabelLeftMargin, statusTextLabelTopMargin);
// statusIconLabel
statusIconLabel->setPixmap(statusIcon.pixmap(KIconLoader::SizeSmall));
//.........这里部分代码省略.........