本文整理汇总了C++中QListView::setUniformItemSizes方法的典型用法代码示例。如果您正苦于以下问题:C++ QListView::setUniformItemSizes方法的具体用法?C++ QListView::setUniformItemSizes怎么用?C++ QListView::setUniformItemSizes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListView
的用法示例。
在下文中一共展示了QListView::setUniformItemSizes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HistoryCompletionModel
WebView *TabWidget::newTab(bool makeCurrent)
{
// line edit
UrlLineEdit *urlLineEdit = new UrlLineEdit;
QLineEdit *lineEdit = urlLineEdit->lineEdit();
if (!m_lineEditCompleter && count() > 0) {
HistoryCompletionModel *completionModel = new HistoryCompletionModel(this);
completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel());
m_lineEditCompleter = new QCompleter(completionModel, this);
// Should this be in Qt by default?
QAbstractItemView *popup = m_lineEditCompleter->popup();
QListView *listView = qobject_cast<QListView*>(popup);
if (listView)
listView->setUniformItemSizes(true);
}
lineEdit->setCompleter(m_lineEditCompleter);
connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()));
m_lineEdits->addWidget(urlLineEdit);
m_lineEdits->setSizePolicy(lineEdit->sizePolicy());
// optimization to delay creating the more expensive WebView, history, etc
if (count() == 0) {
QWidget *emptyWidget = new QWidget;
QPalette p = emptyWidget->palette();
p.setColor(QPalette::Window, palette().color(QPalette::Base));
emptyWidget->setPalette(p);
emptyWidget->setAutoFillBackground(true);
disconnect(this, SIGNAL(currentChanged(int)),
this, SLOT(currentChanged(int)));
addTab(emptyWidget, tr("(Untitled)"));
connect(this, SIGNAL(currentChanged(int)),
this, SLOT(currentChanged(int)));
return 0;
}
示例2: GalleryView
PhotoView::PhotoView(QAbstractGallery *gallery, QWidget *parent, Qt::WindowFlags flags)
: GalleryView(parent, flags)
, model(new ThumbnailModel(gallery))
{
model->setRootType(QDocumentGallery::Image);
QHash<int, QString> properties;
properties.insert(Qt::DisplayRole, QDocumentGallery::fileName);
model->addColumn(properties);
model->setSortPropertyNames(QStringList()
<< QDocumentGallery::title);
QListView *view = new QListView;
view->setIconSize(ThumbnailModel::thumbnailSize);
view->setFlow(QListView::TopToBottom);
view->setViewMode(QListView::IconMode);
view->setUniformItemSizes(true);
view->setWrapping(true);
view->setModel(model.data());
view->setItemDelegate(new PhotoDelegate(this));
connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
QBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(view);
setLayout(layout);
}
示例3: QWidget
Window::Window(QWidget *parent)
: QWidget(parent)
{
FileListModel *model = new FileListModel(this);
model->init();
QLabel *label = new QLabel(tr("&Directory:"));
QLineEdit *lineEdit = new QLineEdit;
label->setBuddy(lineEdit);
QListView *view = new QListView;
view->setModel(model);
view->setUniformItemSizes(true);
connect(lineEdit, SIGNAL(textChanged(QString)), model, SLOT(setDirPath(QString)));
connect(lineEdit, SIGNAL(editingFinished()), model, SLOT(list()));
/*
here: connect the signal of special io thread entry added to the slot entryadded of filelistmodel
*/
QGridLayout *layout = new QGridLayout;
layout->addWidget(label, 0, 0);
layout->addWidget(lineEdit, 0, 1);
layout->addWidget(view, 1, 0, 1, 2);
setLayout(layout);
setWindowTitle(tr("Fetch More Example"));
}
示例4: main
int main(int c, char **v)
{
QApplication a(c, v);
QListView view;
view.setUniformItemSizes(true);
view.setModel(new RandomListModel(&view));
view.show();
return a.exec();
}
示例5: HistoryCompletionModel
WebView *TabWidget::makeNewTab(bool makeCurrent)
{
// line edit
LocationBar *locationBar = new LocationBar;
if (!m_lineEditCompleter) {
HistoryCompletionModel *completionModel = new HistoryCompletionModel(this);
completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel());
m_lineEditCompleter = new HistoryCompleter(completionModel, this);
connect(m_lineEditCompleter, SIGNAL(activated(const QString &)),
this, SLOT(loadString(const QString &)));
// Should this be in Qt by default?
QAbstractItemView *popup = m_lineEditCompleter->popup();
QListView *listView = qobject_cast<QListView*>(popup);
if (listView) {
// Urls are always LeftToRight
listView->setLayoutDirection(Qt::LeftToRight);
listView->setUniformItemSizes(true);
}
}
示例6: QComboBox
/*!
Constructs a font combobox with the given \a parent.
*/
QFontComboBox::QFontComboBox(QWidget *parent)
: QComboBox(*new QFontComboBoxPrivate, parent)
{
Q_D(QFontComboBox);
d->currentFont = font();
setEditable(true);
QStringListModel *m = new QStringListModel(this);
setModel(m);
setItemDelegate(new QFontFamilyDelegate(this));
QListView *lview = qobject_cast<QListView*>(view());
if (lview)
lview->setUniformItemSizes(true);
setWritingSystem(QFontDatabase::Any);
connect(this, SIGNAL(currentIndexChanged(QString)),
this, SLOT(_q_currentChanged(QString)));
connect(qApp, SIGNAL(fontDatabaseChanged()),
this, SLOT(_q_updateModel()));
}
示例7: QDialog
RecipientDialog::RecipientDialog(QWidget* parent, QAbstractListModel* model) :
QDialog(parent)
{
setModal( true );
setWindowTitle( i18n("Select Recipient") );
// Add the layout to the widget
QVBoxLayout* dialogLayout = new QVBoxLayout(this);
// Add the nickname list widget
QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(this);
sortModel->setSortCaseSensitivity(Preferences::self()->sortCaseInsensitive() ? Qt::CaseInsensitive : Qt::CaseSensitive);
sortModel->setSourceModel(model);
sortModel->sort(0, Qt::AscendingOrder);
QListView* nicknameList = new QListView(this);
nicknameList->setUniformItemSizes(true);
nicknameList->setModel(sortModel);
nicknameInput = new KLineEdit(this);
dialogLayout->addWidget(nicknameList);
dialogLayout->addWidget(nicknameInput);
connect(nicknameList, &QListView::clicked, this, &RecipientDialog::newNicknameSelected);
connect(nicknameList, &QListView::doubleClicked, this, &RecipientDialog::newNicknameSelectedQuit);
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
dialogLayout->addWidget(buttonBox);
QPushButton* button = buttonBox->addButton(QDialogButtonBox::Ok);
button->setToolTip(i18n("Select nickname and close the window"));
button->setIcon(SmallIcon("dialog-ok"));
button->setShortcut(Qt::CTRL | Qt::Key_Return);
button->setDefault(true);
button = buttonBox->addButton(QDialogButtonBox::Cancel);
button->setToolTip(i18n("Close the window without changes"));
button->setIcon(SmallIcon("dialog-cancel"));
KWindowConfig::restoreWindowSize(windowHandle(), KConfigGroup(KSharedConfig::openConfig(), "DCCRecipientDialog"));
connect(buttonBox, &QDialogButtonBox::accepted, this, &RecipientDialog::slotOk);
connect(buttonBox, &QDialogButtonBox::rejected, this, &RecipientDialog::slotCancel);
}
示例8: QDialog
::fwActivities::registry::ActivityInfo SCreateActivity::show( const ActivityInfoContainer& infos )
{
QWidget* parent = qApp->activeWindow();
QDialog* dialog = new QDialog(parent);
dialog->setWindowTitle(QString::fromStdString("Choose an activity"));
dialog->resize(600, 400);
QStandardItemModel* model = new QStandardItemModel(dialog);
for( const ::fwActivities::registry::ActivityInfo& info : infos)
{
std::string text;
if(info.title.empty())
{
text = info.id;
}
else
{
text = info.title + (info.description.empty() ? "" : "\n" + info.description);
}
QStandardItem* item = new QStandardItem(QIcon(info.icon.c_str()), QString::fromStdString(text));
item->setData(QVariant::fromValue(info));
item->setEditable(false);
model->appendRow(item);
}
QListView* selectionList = new QListView();
selectionList->setIconSize(QSize(40, 40));
selectionList->setUniformItemSizes(true);
selectionList->setModel(model);
QModelIndex index = model->index( 0, 0 );
if ( index.isValid() )
{
selectionList->selectionModel()->select( index, QItemSelectionModel::Select );
}
QPushButton* okButton = new QPushButton("Ok");
QPushButton* cancelButton = new QPushButton("Cancel");
QHBoxLayout* hLayout = new QHBoxLayout();
hLayout->addWidget(okButton);
hLayout->addWidget(cancelButton);
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->addWidget(selectionList);
vLayout->addLayout(hLayout);
dialog->setLayout(vLayout);
QObject::connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept()));
QObject::connect(cancelButton, SIGNAL(clicked()), dialog, SLOT(reject()));
QObject::connect(selectionList, SIGNAL(doubleClicked(const QModelIndex&)), dialog, SLOT(accept()));
::fwActivities::registry::ActivityInfo info;
if(dialog->exec())
{
QModelIndex currentIndex = selectionList->selectionModel()->currentIndex();
QStandardItem* item = model->itemFromIndex( currentIndex );
QVariant var = item->data();
info = var.value< ::fwActivities::registry::ActivityInfo >();
}
return info;
}