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(); }
void tst_QItemDelegate::uintEdit() { QListView view; QStandardItemModel model; { QStandardItem *data=new QStandardItem; data->setEditable(true); data->setData(QVariant((uint)1), Qt::DisplayRole); model.setItem(0, 0, data); } { QStandardItem *data=new QStandardItem; data->setEditable(true); data->setData(QVariant((uint)1), Qt::DisplayRole); model.setItem(1, 0, data); } view.setModel(&model); view.setEditTriggers(QAbstractItemView::AllEditTriggers); const QModelIndex firstCell = model.index(0, 0); QCOMPARE(firstCell.data(Qt::DisplayRole).userType(), static_cast<int>(QMetaType::UInt)); view.selectionModel()->setCurrentIndex(model.index(0, 0), QItemSelectionModel::Select); view.edit(firstCell); QSpinBox *sb = view.findChild<QSpinBox*>(); QVERIFY(sb); sb->stepUp(); // Select another index to trigger the end of editing. const QModelIndex secondCell = model.index(1, 0); view.selectionModel()->setCurrentIndex(secondCell, QItemSelectionModel::Select); QCOMPARE(firstCell.data(Qt::DisplayRole).userType(), static_cast<int>(QMetaType::UInt)); QCOMPARE(firstCell.data(Qt::DisplayRole).toUInt(), static_cast<uint>(2)); view.edit(secondCell); // The first spinbox is deleted with deleteLater, so it is still there. QList<QSpinBox*> sbList = view.findChildren<QSpinBox*>(); QCOMPARE(sbList.size(), 2); sb = sbList.at(1); sb->stepDown(); // 1 -> 0 sb->stepDown(); // 0 (no effect) sb->stepDown(); // 0 (no effect) // Select another index to trigger the end of editing. view.selectionModel()->setCurrentIndex(firstCell, QItemSelectionModel::Select); QCOMPARE(secondCell.data(Qt::DisplayRole).userType(), static_cast<int>(QMetaType::UInt)); QCOMPARE(secondCell.data(Qt::DisplayRole).toUInt(), static_cast<uint>(0)); }
/*! 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; }
VisualizerPlugin::VisualizerPlugin() { NotedFace::compute()->registerJobSource(this); m_availableDock = new QDockWidget("Available Visualizations", NotedFace::get()); QListView* availableView = new QListView; m_availableDock->setWidget(availableView); m_availableDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar); availableView->setModel(&m_availableModel); availableView->setEditTriggers(QListView::NoEditTriggers); connect(availableView, &QListView::activated, [&](QModelIndex i) { if (Viz v = createViz(m_availableModel.data(i, Qt::DisplayRole).toString().toStdString())) { auto p = new VizGLWidgetProxy(v); NotedFace::get()->addGLView(p); m_active.push_back(p); NotedFace::compute()->invalidate(NotedFace::events()->collateEventsAnalysis()); } }); NotedFace::get()->addDockWidget(Qt::BottomDockWidgetArea, m_availableDock); }
ClientWindow::ClientWindow() { QHBoxLayout* mainLayout = new QHBoxLayout; QVBoxLayout* verticalLayout_2 = new QVBoxLayout; QHBoxLayout* horizontalLayout = new QHBoxLayout; // Clients list QListView* list = new QListView; model = new QStringListModel(clientsList); list->setEditTriggers(QAbstractItemView::NoEditTriggers); list->setModel(model); QLabel* label = new QLabel("Server's IP :"); IPServer = new QLineEdit("127.0.0.1"); IPServer->setMaximumSize(150, 16777215); QLabel* label_2 = new QLabel("Server's port :"); serverPort = new QSpinBox; serverPort->setMinimumSize(60, 0); serverPort->setMinimum(1024); serverPort->setMaximum(65535); serverPort->setValue(50885); connectionButton = new QPushButton("Connect"); connect(connectionButton, SIGNAL(clicked()), this, SLOT(on_connectionButton_clicked())); horizontalLayout->addWidget(label); horizontalLayout->addWidget(IPServer); horizontalLayout->addWidget(label_2); horizontalLayout->addWidget(serverPort); horizontalLayout->addWidget(connectionButton); messageList = new QTextEdit; messageList->setReadOnly(true); QHBoxLayout* horizontalLayout_2 = new QHBoxLayout; QLabel* label_3 = new QLabel("Username :"******"Message :"); message = new QLineEdit; sendButton = new QPushButton("Send"); connect(sendButton, SIGNAL(clicked()), this, SLOT(on_sendButton_clicked())); sendFileButton = new QPushButton("Send a file"); connect(sendFileButton, SIGNAL(clicked()), this, SLOT(on_sendFileButton_clicked())); horizontalLayout_2->addWidget(label_3); horizontalLayout_2->addWidget(username); horizontalLayout_2->addWidget(label_4); horizontalLayout_2->addWidget(message); horizontalLayout_2->addWidget(sendButton); horizontalLayout_2->addWidget(sendFileButton); verticalLayout_2->addLayout(horizontalLayout); verticalLayout_2->addWidget(messageList); verticalLayout_2->addLayout(horizontalLayout_2); mainLayout->addWidget(list); mainLayout->addLayout(verticalLayout_2); setLayout(mainLayout); }