本文整理汇总了C++中QListView::setViewMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QListView::setViewMode方法的具体用法?C++ QListView::setViewMode怎么用?C++ QListView::setViewMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListView
的用法示例。
在下文中一共展示了QListView::setViewMode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QListView *listView = new QListView;
QListView *newListView = new QListView;
QStringList nameItem;
nameItem << "Linux" << "Android" << "Mac OS";
QStandardItemModel *model = new QStandardItemModel(nameItem.length(),1); // initialize row and columns of data model
for(int i = 0; i < model->rowCount(); ++i)
{
QModelIndex modelIndex = model->index(i,0);
QString str = nameItem.at(i);
model->setData(modelIndex,str,Qt::DisplayRole);
model->setData(modelIndex,"ToolTip for" + str,Qt::ToolTipRole);
model->setData(modelIndex,QIcon(":/Images/" + str + ".jpeg"),Qt::DecorationRole);
}
listView->setViewMode(QListView::IconMode);
listView->setModel(model);
listView->setGeometry(430,340,200,200);
newListView->setViewMode(QListView::IconMode);
newListView->setModel(model);
newListView->setGeometry(listView->geometry());
listView->show();
newListView->show();
return a.exec();
}
示例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: addPalette
void AnnotationImagePaletteWidget::addPalette(const QString& path)
{
QListView* pPalette = new QListView(this);
pPalette->setWrapping(true);
pPalette->setLayoutMode(QListView::Batched);
pPalette->setBatchSize(10);
pPalette->setMovement(QListView::Static);
pPalette->setFlow(QListView::LeftToRight);
pPalette->setIconSize(QSize(32, 32));
pPalette->setViewMode(QListView::IconMode);
pPalette->setDragEnabled(true);
pPalette->setDragDropMode(QAbstractItemView::DragOnly);
pPalette->setSelectionMode(QAbstractItemView::SingleSelection);
pPalette->setResizeMode(QListView::Adjust);
if (QFileInfo(path).isDir())
{
QDirModel* pModel = new PaletteModel(this);
pModel->setFilter(QDir::Files | QDir::Readable);
QStringList formats;
QList<QByteArray> rawFormats = QImageReader::supportedImageFormats();
foreach (const QByteArray& rawFormat, rawFormats)
{
formats << "*." + QString(rawFormat);
}
示例4: QWidget
CWirelessSettings::CWirelessSettings(CDevice * wireless, QWidget * parent) : QWidget(parent), m_Device(wireless) {
ui.setupUi(this);
QListView * hiddenListView = new QListView(this);
hiddenListView->hide();
hiddenListView->setViewMode(QListView::IconMode);
hiddenListView->setIconSize(QSize(24, 24));
hiddenListView->setGridSize(QSize(96, 64));
setWindowTitle(tr("QNUT - Wireless Settings for \"%1\"").arg(m_Device->getName()));
setWindowIcon(QIcon(UI_ICON_AP));
ui.nameLabel->setText(m_Device->getName());
m_ManagedAPProxyModel = new CManagedAPProxyModel(this);
m_ManagedAPModel = new CManagedAPModel(m_Device->getWireless()->getWpaSupplicant(), this);
m_ManagedAPProxyModel->setSourceModel(m_ManagedAPModel);
m_AvailableAPProxyModel = new CAvailableAPProxyModel(this);
m_AvailableAPModel = new CAvailableAPModel(m_Device->getWireless()->getHardware(), this);
m_AvailableAPProxyModel->setSourceModel(m_AvailableAPModel);
createActions();
ui.managedView->setModel(m_ManagedAPProxyModel);
ui.availableView->setModel(m_AvailableAPProxyModel);
ui.managedView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui.availableView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
updateUi(m_Device->getState());
ui.managedView->header()->setMinimumSectionSize(-1);
ui.availableView->header()->setMinimumSectionSize(-1);
connect(m_Device, &CDevice::stateChanged, this, &CWirelessSettings::updateUi);
connect(ui.managedView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &CWirelessSettings::handleManagedAPSelectionChanged);
connect(ui.availableView, &QAbstractItemView::doubleClicked, this, &CWirelessSettings::addNetwork);
connect(ui.managedView, &QAbstractItemView::doubleClicked, this, &CWirelessSettings::switchToSelectedNetwork);
connect(ui.availableAPFilterEdit, &QLineEdit::textChanged, m_AvailableAPProxyModel, &CAvailableAPProxyModel::setFilterWildcard);
connect(m_Device->getWireless()->getHardware(), &CWirelessHW::signalQualityUpdated,
this, &CWirelessSettings::updateSignalInfo);
connect(m_AvailableAPModel, &CAvailableAPModel::cachedScansUpdated, this, &CWirelessSettings::updateBSSIDMenu);
}
示例5: main
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(interview);
QApplication app(argc, argv);
QSplitter page;
QAbstractItemModel *data = new Model(1000, 10, &page);
QItemSelectionModel *selections = new QItemSelectionModel(data);
QTableView *table = new QTableView;
table->setModel(data);
table->setSelectionModel(selections);
table->horizontalHeader()->setMovable(true);
table->verticalHeader()->setMovable(true);
// Set StaticContents to enable minimal repaints on resizes.
table->viewport()->setAttribute(Qt::WA_StaticContents);
page.addWidget(table);
QTreeView *tree = new QTreeView;
tree->setModel(data);
tree->setSelectionModel(selections);
tree->setUniformRowHeights(true);
tree->header()->setStretchLastSection(false);
tree->viewport()->setAttribute(Qt::WA_StaticContents);
// Disable the focus rect to get minimal repaints when scrolling on Mac.
tree->setAttribute(Qt::WA_MacShowFocusRect, false);
page.addWidget(tree);
QListView *list = new QListView;
list->setModel(data);
list->setSelectionModel(selections);
list->setViewMode(QListView::IconMode);
list->setSelectionMode(QAbstractItemView::ExtendedSelection);
list->setAlternatingRowColors(false);
list->viewport()->setAttribute(Qt::WA_StaticContents);
list->setAttribute(Qt::WA_MacShowFocusRect, false);
page.addWidget(list);
page.setWindowIcon(QPixmap(":/images/interview.png"));
page.setWindowTitle("Interview");
page.show();
return app.exec();
}
示例6: QWidget
//.........这里部分代码省略.........
//QHBoxLayout *editorHBox = new QHBoxLayout();
//editorHBox->setContentsMargins(0,0,0,0);
QSplitter *editorHBox = new QSplitter();
m_editor = new MyQTextEdit;
m_editor->setFont(font);
editorHBox->addWidget(m_editor);
connect(m_editor, SIGNAL(textChanged()), this, SLOT(editTextChanged()));
//m_editor->setAcceptRichText(false);
m_highlighter = new SongEditorHighlighter(m_editor->document());
// Arrangement preview box
m_arrangementPreview = new MyQTextEdit;
m_arrangementPreview->setFont(font);
m_arrangementPreview->setReadOnly(true);
QPalette p2 = m_arrangementPreview->palette();
p2.setColor(QPalette::Base, Qt::lightGray);
m_arrangementPreview->setPalette(p2);
editorHBox->addWidget(m_arrangementPreview);
//m_editor->setAcceptRichText(false);
(void*)new SongEditorHighlighter(m_arrangementPreview->document());
// List view
m_arrModel = new ArrangementListModel();
connect(m_arrModel, SIGNAL(blockListChanged(QStringList)), this, SLOT(arrModelChange(QStringList)));
QListView *arrListView = new QListView();
arrListView->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding));
arrListView->setViewMode(QListView::ListMode);
arrListView->setWrapping(false);
arrListView->setFlow(QListView::TopToBottom);
arrListView->setMovement(QListView::Free);
arrListView->setWordWrap(true);
arrListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
arrListView->setDragEnabled(true);
arrListView->setAcceptDrops(true);
arrListView->setDropIndicatorShown(true);
arrListView->setModel(m_arrModel);
m_arrListView = arrListView;
editorHBox->addWidget(arrListView);
editorHBox->setStretchFactor(0,10);
editorHBox->setStretchFactor(1,10);
editorHBox->setStretchFactor(2,1);
//vbox->addWidget(m_editor);
//vbox->addLayout(editorHBox);
vbox->addWidget(editorHBox);
QHBoxLayout * hboxBottom = new QHBoxLayout();
m_tmplEditButton = new QPushButton("Edit &Template...");
m_tmplEditButton->setIcon(QIcon(":data/stock-select-color.png"));
m_tmplEditButton->setToolTip("Edit the template associated with this song arrangement");
connect(m_tmplEditButton, SIGNAL(clicked()), this, SLOT(editSongTemplate()));
hboxBottom->addWidget(m_tmplEditButton);
QPushButton *tmplResetButton = new QPushButton("");