本文整理汇总了C++中QListView::setSelectionMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QListView::setSelectionMode方法的具体用法?C++ QListView::setSelectionMode怎么用?C++ QListView::setSelectionMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListView
的用法示例。
在下文中一共展示了QListView::setSelectionMode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addBook
void MainWindow::addBook()
{
//Multiselection file dialog
//http://www.qtcentre.org/threads/34226-QFileDialog-select-multiple-directories?p=220108#post220108
QFileDialog getBookListDialog(this,"Choose Book to Convert",lastSelectDir);
getBookListDialog.setFileMode(QFileDialog::DirectoryOnly);
getBookListDialog.setOption(QFileDialog::DontUseNativeDialog,true);
QListView *l = getBookListDialog.findChild<QListView*>("listView");
if (l)
{
l->setSelectionMode(QAbstractItemView::ExtendedSelection);
}
QTreeView *t = getBookListDialog.findChild<QTreeView*>("treeView");
if (t)
{
t->setSelectionMode(QAbstractItemView::ExtendedSelection);
}
//
if(getBookListDialog.exec() == QDialog::Accepted)
{
ui->listWidget->addItems(getBookListDialog.selectedFiles());
}
this->lastSelectDir = getBookListDialog.directory().absolutePath();
}
示例2: on_pushButtonFilter_clicked
void WidgetMain::on_pushButtonFilter_clicked()
{
filterFolderPaths_.clear();
QFileDialog fileDialog(this, "select folder ", "./");
fileDialog.setFileMode(QFileDialog::DirectoryOnly);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, true);
QListView *pListView = fileDialog.findChild<QListView*>("listView");
if(NULL != pListView)
{
qDebug() << "find listview!";
pListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
}
if(fileDialog.exec())
{
QStringList folderPaths = fileDialog.selectedFiles();
if(folderPaths.isEmpty())
{
qDebug() << "folders is empty!";
return;
}
#ifdef WIN32
foreach (QString tmp, folderPaths)
{
filterFolderPaths_ << tmp.replace("/", "\\");
}
示例3: QMenu
MainWindow::MainWindow()
{
QMenu *fileMenu = new QMenu(tr("&File"));
QAction *quitAction = fileMenu->addAction(tr("E&xit"));
quitAction->setShortcut(tr("Ctrl+Q"));
menuBar()->addMenu(fileMenu);
// For convenient quoting:
//! [0]
QListView *listView = new QListView(this);
listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
listView->setDragEnabled(true);
listView->setAcceptDrops(true);
listView->setDropIndicatorShown(true);
//! [0]
this->listView = listView;
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
setupListItems();
setCentralWidget(listView);
setWindowTitle(tr("List View"));
}
示例4: buildFileBrowser
void MainWindow::buildFileBrowser()
{
QString rootPath = qgetenv("HOME");
this->drivesModel->setFilter(QDir::NoDotAndDotDot | QDir::Dirs);
QTreeView *treeView = this->treeView = new QTreeView(this->ui->dockDir);
treeView->setModel(this->drivesModel);
treeView->setRootIndex(this->drivesModel->setRootPath(rootPath + "/../"));
treeView->hideColumn(1);
treeView->hideColumn(2);
treeView->hideColumn(3);
treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
treeView->setDragEnabled(true);
treeView->setDragDropMode(QAbstractItemView::DragOnly);
this->ui->dockDir->setWidget(treeView);
this->filesModel->setFilter(QDir::NoDotAndDotDot | QDir::Files);
QListView *listView = this->listView = new QListView(this->ui->dockFile);
listView->setModel(this->filesModel);
listView->setRootIndex(this->filesModel->setRootPath(rootPath));
listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
listView->setDragEnabled(true);
listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
this->ui->dockFile->setWidget(listView);
listView->show();
treeView->show();
}
示例5: 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);
}
示例6: selectFiles
QFileDialog* selectFiles(QString title, QString dir, QString nameString, QString nameExt) {
QFileDialog* finder = new QFileDialog();
finder->setWindowTitle(title);
finder->setDirectory(dir);
finder->setNameFilter(nameString + "(" + nameExt + ")");
QListView *l = finder->findChild<QListView*>("listView");
if (l)
l->setSelectionMode(QAbstractItemView::ExtendedSelection);
QTreeView *t = finder->findChild<QTreeView*>();
if (t)
t->setSelectionMode(QAbstractItemView::ExtendedSelection);
return finder;
}
示例7: on_tool_adddirs_clicked
void ConfigUI::on_tool_adddirs_clicked(){
QFileDialog dlg(this);
dlg.setFileMode(QFileDialog::DirectoryOnly);
QListView *l = dlg.findChild<QListView*>("listView");
if(l){ l->setSelectionMode(QAbstractItemView::MultiSelection); }
QTreeView *t = dlg.findChild<QTreeView*>();
if(t){ t->setSelectionMode(QAbstractItemView::MultiSelection); }
dlg.setDirectory(QDir::homePath());
dlg.setWindowTitle( tr("Exclude Directories") );
if(dlg.exec()){
//Directories selected
QStringList paths = dlg.selectedFiles();
ui->list_excludes->addItems(paths);
}
}
示例8: setPopup
/*!
Returns the popup used to display completions.
\sa setPopup()
*/
QAbstractItemView *QCompleter::popup() const
{
Q_D(const QCompleter);
#ifndef QT_NO_LISTVIEW
if (!d->popup && completionMode() != QCompleter::InlineCompletion) {
QListView *listView = new QListView;
listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
listView->setSelectionBehavior(QAbstractItemView::SelectRows);
listView->setSelectionMode(QAbstractItemView::SingleSelection);
listView->setModelColumn(d->column);
QCompleter *that = const_cast<QCompleter*>(this);
that->setPopup(listView);
}
#endif // QT_NO_LISTVIEW
return d->popup;
}
示例9: 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();
}
示例10: askForDirectories
/**
* Ask the user to choose one or more directories.
* TODO: browse the remotes directories (Core) not the local ones.
*/
QStringList Utils::askForDirectories(QSharedPointer<RCC::ICoreConnection> coreConnection, const QString& message)
{
if (coreConnection->isLocal())
{
QFileDialog fileDialog(0, "Choose a directory");
fileDialog.setOption(QFileDialog::DontUseNativeDialog, true);
fileDialog.setFileMode(QFileDialog::Directory);
if (!message.isNull())
{
QGridLayout* layout = fileDialog.findChild<QGridLayout*>();
QLabel* label = new QLabel(message, &fileDialog);
layout->addWidget(label, layout->rowCount(), 0, 1, -1, Qt::AlignLeft | Qt::AlignVCenter);
}
QListView* l = fileDialog.findChild<QListView*>("listView");
if (l)
l->setSelectionMode(QAbstractItemView::ExtendedSelection);
if (fileDialog.exec())
{
return fileDialog.selectedFiles();
}
return QStringList();
}
else
{
RemoteFileDialog fileDialog;
fileDialog.setWindowTitle("Remote directory");
fileDialog.setText("Remote directory to share : ");
if (fileDialog.exec())
{
return QStringList() << fileDialog.getFolder();
}
return QStringList();
}
}
示例11: QWidget
//.........这里部分代码省略.........
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("");
tmplResetButton->setIcon(QIcon(":data/stock-undo.png"));
tmplResetButton->setToolTip("Reset template on this song to use the current template set in the main Song Browser");
connect(tmplResetButton, SIGNAL(clicked()), this, SLOT(resetSongTemplate()));
hboxBottom->addWidget(tmplResetButton);
hboxBottom->addStretch();
示例12: QFileDialog
MultiQFileDialog::MultiQFileDialog(QWidget *parent, const QString &caption, const QString &directory, bool multiSelect, const QString &filter)
: QFileDialog(parent, caption, directory, filter)
{
this->showHidden = false;
this->multiSelect = multiSelect;
setOption(QFileDialog::DontUseNativeDialog, false);
if (multiSelect)
{
setOption(QFileDialog::DontUseNativeDialog, true);
le = findChild<QLineEdit*>(QString::fromUtf8("fileNameEdit"));
QListView *l = findChild<QListView*>(QString::fromUtf8("listView"));
if (l)
{
l->setSelectionMode(QListView::ExtendedSelection);
if (le)
{
connect(l->selectionModel(),
SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
this,
SLOT(onSelectionChanged ( const QItemSelection &, const QItemSelection & )));
}
}
QTreeView *t = findChild<QTreeView*>();
if (t)
{
t->setSelectionMode(QAbstractItemView::ExtendedSelection);
if (le)
{
connect(t->selectionModel(),
SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
this,
SLOT(onSelectionChanged ( const QItemSelection &, const QItemSelection & )));
}
}
QLabel *label = findChild<QLabel*>(QString::fromUtf8("fileNameLabel"));
if (label)
{
label->hide();
}
label = findChild<QLabel*>(QString::fromUtf8("fileTypeLabel"));
if (label)
{
label->hide();
}
label = findChild<QLabel*>(QString::fromUtf8("lookInLabel"));
if (label)
{
label->hide();
}
QDialogButtonBox *buttonBox = findChild<QDialogButtonBox*>(QString::fromUtf8("buttonBox"));
if (buttonBox)
{
buttonBox->button(QDialogButtonBox::Open)->setText(QCoreApplication::translate("QDialogButtonBox", "&OK"));
}
setFileMode(QFileDialog::ExistingFiles);
if (le)
{
le->setText(QCoreApplication::translate("ShellExtension", "Upload to MEGA"));
}
}
QList<QWidget *> widgets = findChildren<QWidget *>();
for (QList<QWidget *>::const_iterator it = widgets.begin(); it != widgets.end(); ++it)
{
(*it)->installEventFilter(this);
}
installEventFilter(this);
}