本文整理汇总了C++中QCheckBox::sizeHint方法的典型用法代码示例。如果您正苦于以下问题:C++ QCheckBox::sizeHint方法的具体用法?C++ QCheckBox::sizeHint怎么用?C++ QCheckBox::sizeHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCheckBox
的用法示例。
在下文中一共展示了QCheckBox::sizeHint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sceneChanged
void GroupSelWidget::sceneChanged()
{
QSet<QString> groupSet = _scene->getAllGroups();
if(groupSet == _prevGroupSet)
return;
_prevGroupSet = groupSet;
QList<QString> groups = groupSet.toList();
qSort(groups);
for(int i = 0; i < (int)_checkBoxes.size(); ++i)
delete _checkBoxes[i];
_checkBoxes.clear();
int childWidth = 0;
for(int i = 0; i < (int)groups.size(); ++i) {
QCheckBox *box = new QCheckBox(groups[i], this);
QFont font = box->font();
font.setPointSize(14);
box->setFont(font);
box->setCheckState(_scene->isGroupVisible(groups[i]) ? Qt::Checked : Qt::Unchecked);
new VisibilitySetter(box, _scene, groups[i]);
layout()->addWidget(box);
childWidth = max(childWidth, box->sizeHint().width());
_checkBoxes.push_back(box);
}
setMinimumWidth(150);
QWidget *scrollArea = parentWidget()->parentWidget()->parentWidget();
scrollArea->setMinimumWidth(childWidth + 20);
}
示例2: QDialog
KFindTextDialog::KFindTextDialog( QWidget *parent, const char *name )
: QDialog( parent, name )
{
// mimimise initial size of dialog
resize( 0, 0 );
QVBoxLayout *vl = new QVBoxLayout( this, 15 );
QHBoxLayout *hl = new QHBoxLayout( 15 );
vl->addLayout( hl );
QLabel *label = new QLabel( i18n( "Find:" ), this );
label->setFixedSize( label->sizeHint() );
QLineEdit *edit = new QLineEdit( this );
edit->setFixedHeight( edit->sizeHint().height() );
edit->setFocus();
connect( edit, SIGNAL( textChanged( const char * ) ),
SLOT( slotTextChanged( const char * ) ) );
hl->addWidget( label );
hl->addWidget( edit );
hl = new QHBoxLayout;
vl->addLayout( hl );
QCheckBox *cb = new QCheckBox( i18n( "Case &sensitive" ), this );
connect( cb, SIGNAL( toggled( bool ) ), this, SLOT( slotCase( bool ) ) );
cb->setFixedSize( cb->sizeHint() );
hl->addWidget( cb );
hl->addStretch();
hl = new QHBoxLayout( 15 );
vl->addLayout( hl );
QPushButton *btn = new QPushButton( i18n( "&Find" ), this );
btn->setFixedSize( btn->sizeHint() );
btn->setDefault( true );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotFind() ) );
hl->addWidget( btn );
hl->addStretch();
btn = new QPushButton( i18n( "&Close" ), this );
btn->setFixedSize( btn->sizeHint() );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotClose() ) );
hl->addWidget( btn );
vl->activate();
rExp.setCaseSensitive( false );
}
示例3: QDialog
FieldSelect::FieldSelect(Procview *pv, Proc *proc)
: QDialog(0, "select fields"),
nbuttons(proc->cats.size()),
disp_fields(nbuttons),
procview(pv)
{
QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
updating = FALSE;
setCaption("qps: select fields");
buts = new QCheckBox*[nbuttons];
QGridLayout *l1 = new QGridLayout((nbuttons + 1) / 2, 5, 0);
tl->addLayout(l1, 1);
l1->addColSpacing(2, 15);
int half = (nbuttons + 1) / 2;
for(int i = 0; i < nbuttons; i++) {
QCheckBox *but = new QCheckBox(proc->cats[i]->name, this);
QLabel *desc = new QLabel(proc->cats[i]->help, this);
but->setMinimumSize(but->sizeHint());
desc->setMinimumSize(desc->sizeHint());
if(i < half) {
l1->addWidget(but, i, 0);
l1->addWidget(desc, i, 1);
} else {
l1->addWidget(but, i-half, 3);
l1->addWidget(desc, i-half, 4);
}
buts[i] = but;
connect(but, SIGNAL(toggled(bool)), this, SLOT(field_toggled(bool)));
}
update_boxes();
KButtonBox *bbox = new KButtonBox(this);
bbox->addStretch(1);
QPushButton *closebut = bbox->addButton(i18n("Close"));
closebut->setDefault(TRUE);
closebut->setFocus();
closebut->setFixedSize(closebut->sizeHint());
bbox->layout();
tl->addWidget(bbox);
connect(closebut, SIGNAL(clicked()), SLOT(closed()));
QAccel *acc = new QAccel(this);
acc->connectItem(acc->insertItem(CTRL + Key_W),
this, SLOT(closed()));
tl->freeze();
}
示例4: 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);
}
示例5: QWidget
DataFilesList::DataFilesList(Files::ConfigurationManager &cfg, QWidget *parent)
: QWidget(parent)
, mCfgMgr(cfg)
{
// Models
mMastersModel = new DataFilesModel(this);
mPluginsModel = new DataFilesModel(this);
mPluginsProxyModel = new QSortFilterProxyModel();
mPluginsProxyModel->setDynamicSortFilter(true);
mPluginsProxyModel->setSourceModel(mPluginsModel);
// Filter toolbar
QLabel *filterLabel = new QLabel(tr("&Filter:"), this);
LineEdit *filterLineEdit = new LineEdit(this);
filterLabel->setBuddy(filterLineEdit);
QToolBar *filterToolBar = new QToolBar(this);
filterToolBar->setMovable(false);
// Create a container widget and a layout to get the spacer to work
QWidget *filterWidget = new QWidget(this);
QHBoxLayout *filterLayout = new QHBoxLayout(filterWidget);
QSpacerItem *hSpacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
filterLayout->addItem(hSpacer1);
filterLayout->addWidget(filterLabel);
filterLayout->addWidget(filterLineEdit);
filterToolBar->addWidget(filterWidget);
QCheckBox checkBox;
unsigned int height = checkBox.sizeHint().height() + 4;
mMastersTable = new QTableView(this);
mMastersTable->setModel(mMastersModel);
mMastersTable->setObjectName("MastersTable");
mMastersTable->setSelectionBehavior(QAbstractItemView::SelectRows);
mMastersTable->setSelectionMode(QAbstractItemView::SingleSelection);
mMastersTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
mMastersTable->setAlternatingRowColors(true);
mMastersTable->horizontalHeader()->setStretchLastSection(true);
mMastersTable->horizontalHeader()->hide();
// Set the row height to the size of the checkboxes
mMastersTable->verticalHeader()->setDefaultSectionSize(height);
mMastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
mMastersTable->verticalHeader()->hide();
mMastersTable->setColumnHidden(1, true);
mMastersTable->setColumnHidden(2, true);
mMastersTable->setColumnHidden(3, true);
mMastersTable->setColumnHidden(4, true);
mMastersTable->setColumnHidden(5, true);
mMastersTable->setColumnHidden(6, true);
mMastersTable->setColumnHidden(7, true);
mMastersTable->setColumnHidden(8, true);
mPluginsTable = new QTableView(this);
mPluginsTable->setModel(mPluginsProxyModel);
mPluginsTable->setObjectName("PluginsTable");
mPluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
mPluginsTable->setSelectionMode(QAbstractItemView::SingleSelection);
mPluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
mPluginsTable->setAlternatingRowColors(true);
mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
mPluginsTable->horizontalHeader()->setStretchLastSection(true);
mPluginsTable->horizontalHeader()->hide();
mPluginsTable->verticalHeader()->setDefaultSectionSize(height);
mPluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
mPluginsTable->setColumnHidden(1, true);
mPluginsTable->setColumnHidden(2, true);
mPluginsTable->setColumnHidden(3, true);
mPluginsTable->setColumnHidden(4, true);
mPluginsTable->setColumnHidden(5, true);
mPluginsTable->setColumnHidden(6, true);
mPluginsTable->setColumnHidden(7, true);
mPluginsTable->setColumnHidden(8, true);
// Add both tables to a splitter
QSplitter *splitter = new QSplitter(this);
splitter->setOrientation(Qt::Horizontal);
splitter->addWidget(mMastersTable);
splitter->addWidget(mPluginsTable);
// Adjust the default widget widths inside the splitter
QList<int> sizeList;
sizeList << 175 << 200;
splitter->setSizes(sizeList);
QVBoxLayout *pageLayout = new QVBoxLayout(this);
pageLayout->addWidget(filterToolBar);
pageLayout->addWidget(splitter);
connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
connect(mMastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
connect(mMastersModel, SIGNAL(checkedItemsChanged(QStringList,QStringList)), mPluginsModel, SLOT(slotcheckedItemsChanged(QStringList,QStringList)));
//.........这里部分代码省略.........
示例6: font
FindDialog::FindDialog(EditorPane *parent, bool replace, bool hasSelection)
: QDialog(parent), m_parent(parent), m_searching(false), m_modifiable(true)
{
QStyle *style = new QCleanlooksStyle();
setFont(QFont("arial", 10));
const QFont font("arial", 9);
// assure EditorPane is notified upon invocation of find/replace
// connect(this, SIGNAL(accepted()), m_parent, SLOT(findDialogInvoked()));
setWindowTitle(tr("Find"));
QGridLayout *mainLayout = new QGridLayout();
QVBoxLayout *layout = new QVBoxLayout();
// Find section
QGroupBox *box = new QGroupBox(tr("Find"), this);
box->setStyle(style);
QLabel *label = new QLabel(tr("Text to find:"), this);
m_lineEdit = new QLineEdit(this);
connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(accept()));
m_regularExpression = new QCheckBox(tr("Regular e&xpression"), this);
m_regularExpression->setStyle(style);
m_regularExpression->setFont(font);
layout->addWidget(label);
layout->addWidget(m_lineEdit);
layout->addWidget(m_regularExpression);
layout->addStretch(1);
box->setLayout(layout);
mainLayout->addWidget(box, 0, 0, 1, 3);
// Replace section
m_replaceWidget = new ReplaceWidget(this, style);
m_replaceWidget->setChecked(replace);
connect(m_replaceWidget, SIGNAL(toggled(bool)), this, SLOT(updateReplace(bool)));
mainLayout->addWidget(m_replaceWidget, 1, 0, 1, 3);
// Options section
QGridLayout *l = new QGridLayout();
box = new QGroupBox(tr("Options"), this);
box->setStyle(style);
QCheckBox *b = new QCheckBox(tr("C&ase sensitive"), this);
m_caseSensitive = b;
b->setStyle(style);
b->setFont(font);
l->addWidget(b, 0, 0);
b = new QCheckBox(tr("&Whole words only"), this);
m_wholeWordsOnly = b;
b->setStyle(style);
b->setFont(font);
l->addWidget(b, 1, 0);
l->setColumnMinimumWidth(0, b->sizeHint().width() + 10); // hack cause this layout manager apparently has trouble w/ multiple styles
b = new QCheckBox(tr("From c&ursor"), this);
m_fromCursor = b;
b->setStyle(style);
b->setFont(font);
l->addWidget(b, 2, 0);
b = new QCheckBox(tr("Find &backwards"), this);
m_findBackwards = b;
b->setStyle(style);
b->setFont(font);
l->addWidget(b, 0, 1);
b = new QCheckBox(tr("&Search selection"), this);
m_searchSelection = b;
b->setStyle(style);
b->setFont(font);
b->setEnabled(hasSelection);
l->setColumnMinimumWidth(1, b->sizeHint().width() + 10); // hack cause this layout manager apparently has trouble w/ multiple styles
connect(m_parent, SIGNAL(copyAvailabile(bool)), b, SLOT(setEnabled(bool)));
l->addWidget(b, 1, 1);
/* b = new QCheckBox(tr("&Prompt on replace"), this);
m_promptOnReplace = b;
b->setStyle(style);
b->setEnabled(replace);
connect(m_replaceWidget, SIGNAL(toggled(bool)), b, SLOT(setEnabled(bool)));
l->addWidget(b, 2, 1);*/
box->setLayout(l);
mainLayout->addWidget(box, 2, 0, 1, 3);
// Bottom buttons (invoke, cancel, replaceAll)
m_invoked = new QPushButton((replace ? "&Replace" : "&Find"));
m_invoked->setAutoDefault(true);
m_invoked->setStyle(style);
connect(m_invoked, SIGNAL(clicked()), this, SLOT(accept()));
mainLayout->addWidget(m_invoked, 3, 0);//, Qt::AlignRight);
m_cancel = new QPushButton("&Cancel");
m_cancel->setAutoDefault(false);
m_cancel->setStyle(style);
connect(m_cancel, SIGNAL(clicked()), this, SLOT(reject()));
mainLayout->addWidget(m_cancel, 3, 2);//, Qt::AlignRight);
m_replaceAll = new QPushButton("Replace &All");
m_replaceAll->setAutoDefault(false);
m_replaceAll->setStyle(style);
connect(m_replaceAll, SIGNAL(clicked()), this, SLOT(replaceAll()));
//.........这里部分代码省略.........