本文整理汇总了C++中KPushButton::sizeHint方法的典型用法代码示例。如果您正苦于以下问题:C++ KPushButton::sizeHint方法的具体用法?C++ KPushButton::sizeHint怎么用?C++ KPushButton::sizeHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KPushButton
的用法示例。
在下文中一共展示了KPushButton::sizeHint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addButton
int DialogPage::addButton(const KGuiItem& item)
{
int id = d->mButtons.size();
KPushButton* button = new KPushButton(item);
button->setFixedHeight(button->sizeHint().height() * 2);
connect(button, SIGNAL(clicked()), d->mMapper, SLOT(map()));
d->mLayout->addWidget(button);
d->mMapper->setMapping(button, id);
d->mButtons << button;
return id;
}
示例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: createGroupBox
QGroupBox *
SelectableSubtitleDialog::createSubtitleGroupBox(const QString &title, bool addToLayout)
{
m_subtitleGroupBox = createGroupBox(title, addToLayout);
m_subtitleUrlLineEdit = new KLineEdit(m_subtitleGroupBox);
m_subtitleUrlLineEdit->setCompletionObject(new KUrlCompletion());
QLabel *subtitlePathLabel = new QLabel(m_subtitleGroupBox);
subtitlePathLabel->setText(i18n("Path:"));
subtitlePathLabel->setBuddy(m_subtitleUrlLineEdit);
KPushButton *subtitleButton = new KPushButton(m_subtitleGroupBox);
subtitleButton->setIcon(KIcon("document-open"));
subtitleButton->setToolTip(i18n("Select subtitle"));
int buttonSize = subtitleButton->sizeHint().height();
subtitleButton->setFixedSize(buttonSize, buttonSize);
connect(subtitleButton, SIGNAL(clicked()), SLOT(selectSubtitle()));
m_subtitleEncodingComboBox = new KComboBox(m_subtitleGroupBox);
m_subtitleEncodingComboBox->addItem(i18n("Autodetect"));
m_subtitleEncodingComboBox->addItems(app()->availableEncodingNames());
m_subtitleEncodingComboBox->setCurrentIndex(0);
QLabel *subtitleEncodingLabel = new QLabel(m_subtitleGroupBox);
subtitleEncodingLabel->setText(i18n("Encoding:"));
subtitleEncodingLabel->setBuddy(m_subtitleEncodingComboBox);
QHBoxLayout *subtitlePathLayout = new QHBoxLayout();
subtitlePathLayout->addWidget(m_subtitleUrlLineEdit, 2);
subtitlePathLayout->addWidget(subtitleButton);
QHBoxLayout *subtitleEncodingLayout = new QHBoxLayout();
subtitleEncodingLayout->addWidget(m_subtitleEncodingComboBox);
subtitleEncodingLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
m_subtitleLayout = createLayout(m_subtitleGroupBox);
m_subtitleLayout->setColumnStretch(1, 2);
m_subtitleLayout->addWidget(subtitlePathLabel, 0, 0, Qt::AlignRight | Qt::AlignVCenter);
m_subtitleLayout->addLayout(subtitlePathLayout, 0, 1, 1, 2);
m_subtitleLayout->addWidget(subtitleEncodingLabel, 1, 0, Qt::AlignRight | Qt::AlignVCenter);
m_subtitleLayout->addLayout(subtitleEncodingLayout, 1, 1);
return m_subtitleGroupBox;
}