本文整理汇总了C++中QListView::setDragEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QListView::setDragEnabled方法的具体用法?C++ QListView::setDragEnabled怎么用?C++ QListView::setDragEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListView
的用法示例。
在下文中一共展示了QListView::setDragEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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"));
}
示例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
//.........这里部分代码省略.........
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();