本文整理汇总了C++中QTableView::selectionModel方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableView::selectionModel方法的具体用法?C++ QTableView::selectionModel怎么用?C++ QTableView::selectionModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableView
的用法示例。
在下文中一共展示了QTableView::selectionModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_signMessage_clicked
void AddressBookPage::on_signMessage_clicked()
{
QTableView *table = ui->tableView;
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
QString addr;
foreach (QModelIndex index, indexes)
{
QVariant address = index.data();
addr = address.toString();
}
示例2: selectionChanged
void AcceptedOfferListPage::selectionChanged()
{
// Set button states based on selected tab and selection
QTableView *table = ui->tableView;
if(!table->selectionModel())
return;
if(table->selectionModel()->hasSelection())
{
ui->copyOffer->setEnabled(true);
ui->messageButton->setEnabled(true);
ui->detailButton->setEnabled(true);
}
else
{
ui->copyOffer->setEnabled(false);
ui->messageButton->setEnabled(false);
ui->detailButton->setEnabled(false);
}
}
示例3: on_giveButton_clicked
void AddressBookPage::on_giveButton_clicked()
{
QTableView *table = ui->tableView;
QModelIndex index;
if (!table->selectionModel())
return;
QModelIndexList indexes = table->selectionModel()->selectedRows(1);
if(!indexes.isEmpty())
{
index = indexes.at(0);
QString pubKey = index.data().toString(), label = index.sibling(index.row(), 0).data(Qt::EditRole).toString();
QMetaObject::invokeMethod(this->parent()->parent(), "gotoSendCoinsGiftPage", GUIUtil::blockingGUIThreadConnection(),
Q_ARG(QString, pubKey),
Q_ARG(QString, label));
}
}
示例4: on_copyToClipboard_clicked
void AddressBookDialog::on_copyToClipboard_clicked()
{
// Copy currently selected address to clipboard
// (or nothing, if nothing selected)
QTableView *table = getCurrentTable();
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
foreach (QModelIndex index, indexes)
{
QVariant address = index.data();
QApplication::clipboard()->setText(address.toString());
}
示例5: selectionChanged
void MyCertListPage::selectionChanged()
{
// Set button states based on selected tab and selection
QTableView *table = ui->tableView;
if(!table->selectionModel())
return;
if(table->selectionModel()->hasSelection())
{
ui->copyCert->setEnabled(true);
ui->sellCertButton->setEnabled(true);
ui->editButton->setEnabled(true);
ui->transferButton->setEnabled(true);
}
else
{
ui->copyCert->setEnabled(false);
ui->sellCertButton->setEnabled(false);
ui->editButton->setEnabled(false);
ui->transferButton->setEnabled(false);
}
}
示例6: done
void AddressBookPage::done(int retval)
{
QTableView *table = ui->tableView;
if(!table->selectionModel() || !table->model())
return;
// Figure out which address was selected, and return it
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
for (const QModelIndex& index : indexes) {
QVariant address = table->model()->data(index);
returnValue = address.toString();
}
if(returnValue.isEmpty())
{
// If no address entry selected, return rejected
retval = Rejected;
}
QDialog::done(retval);
}
示例7: selectionChanged
void AddressBookPage::selectionChanged()
{
// Set button states based on selected tab and selection
QTableView *table = ui->tableView;
if(!table->selectionModel())
return;
if(table->selectionModel()->hasSelection())
{
switch(tab)
{
case SendingTab:
// In sending tab, allow deletion of selection
ui->deleteButton->setEnabled(true);
ui->deleteButton->setVisible(true);
deleteAction->setEnabled(true);
ui->signMessage->setEnabled(false);
ui->signMessage->setVisible(false);
break;
case ReceivingTab:
// Deleting receiving addresses, however, is not allowed
ui->deleteButton->setEnabled(false);
ui->deleteButton->setVisible(false);
deleteAction->setEnabled(false);
ui->signMessage->setEnabled(true);
ui->signMessage->setVisible(true);
break;
}
ui->copyToClipboard->setEnabled(true);
ui->showQRCode->setEnabled(true);
}
else
{
ui->deleteButton->setEnabled(false);
ui->showQRCode->setEnabled(false);
ui->copyToClipboard->setEnabled(false);
ui->signMessage->setEnabled(false);
}
}
示例8: selectionChanged
void InvoicePage::selectionChanged()
{
// Set button states based on selected tab and selection
QTableView *table = ui->tableView;
if(!table->selectionModel())
return;
if(table->selectionModel()->hasSelection())
{
replyAction->setEnabled(true);
copyFromAddressAction->setEnabled(true);
copyToAddressAction->setEnabled(true);
deleteAction->setEnabled(true);
ui->copyFromAddressButton->setEnabled(true);
ui->copyToAddressButton->setEnabled(true);
ui->replyButton->setEnabled(true);
ui->deleteButton->setEnabled(true);
// Figure out which message was selected, and return it
QModelIndexList typeColumn = table->selectionModel()->selectedRows(InvoiceTableModel::Type);
foreach (QModelIndex index, typeColumn)
{
bool sent = (table->model()->data(index).toString() == MessageModel::Sent);
resendAction->setEnabled(sent);
ui->resendButton->setEnabled(sent);
ui->resendButton->setVisible(sent);
receiptAction->setEnabled(sent);
ui->receiptButton->setEnabled(sent);
ui->receiptButton->setVisible(sent);
//payAction->setEnabled(!sent);
//ui->payButton->setEnabled(!sent);
//ui->payButton->setVisible(!sent);
}
示例9: selectionChanged
void MessagePage::selectionChanged()
{
// Set button states based on selected tab and selection
QTableView *table = ui->tableView;
if(!table->selectionModel())
return;
if(table->selectionModel()->hasSelection())
{
replyAction->setEnabled(true);
copyFromAddressAction->setEnabled(true);
copyToAddressAction->setEnabled(true);
deleteAction->setEnabled(true);
ui->copyFromAddressButton->setEnabled(true);
ui->copyToAddressButton->setEnabled(true);
ui->deleteButton->setEnabled(true);
ui->newButton->setEnabled(false);
ui->newButton->setVisible(false);
ui->sendButton->setEnabled(true);
ui->sendButton->setVisible(true);
ui->messageEdit->setVisible(true);
ui->tableView->hide();
// Figure out which message was selected
QModelIndexList labelColumn = table->selectionModel()->selectedRows(MessageModel::Label);
QModelIndexList addressFromColumn = table->selectionModel()->selectedRows(MessageModel::FromAddress);
QModelIndexList addressToColumn = table->selectionModel()->selectedRows(MessageModel::ToAddress);
QModelIndexList typeColumn = table->selectionModel()->selectedRows(MessageModel::Type);
int type;
foreach (QModelIndex index, typeColumn)
type = table->model()->data(index).toInt();
foreach (QModelIndex index, labelColumn)
ui->contactLabel->setText(table->model()->data(index).toString());
foreach (QModelIndex index, addressFromColumn)
if(type == MessageTableEntry::Sent)
replyFromAddress = table->model()->data(index).toString();
else
replyToAddress = table->model()->data(index).toString();
foreach (QModelIndex index, addressToColumn)
if(type == MessageTableEntry::Sent)
replyToAddress = table->model()->data(index).toString();
else
replyFromAddress = table->model()->data(index).toString();
QString filter = replyToAddress;
//QString filter = replyFromAddress;
ui->messageDetails->show();
ui->listConversation->setCurrentIndex(model->proxyModel->index(0, 0, QModelIndex()));
}
示例10: selectionChanged
void ShoppingPage::selectionChanged()
{
// Set button states based on selected tab and selection
QTableView *table = ui->tableView;
if(!table->selectionModel())
return;
if(table->selectionModel()->hasSelection())
{
switch(tab)
{
case SendingTab:
// In sending tab, allow deletion of selection
deleteAction->setEnabled(true);
break;
case ReceivingTab:
// Deleting receiving addresses, however, is not allowed
deleteAction->setEnabled(false);
break;
}
}
}
示例11: eventFilter
bool RequestsForm::eventFilter(QObject *obj, QEvent *event)
{
QTableView *table = qobject_cast<QTableView *>(obj);
if (table && event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Delete) {
QModelIndexList indexes = table->selectionModel()->selectedRows();
removeRequests(indexes);
return true;
}
}
return QObject::eventFilter(obj, event);
}
示例12: RemoveGroup
void QmitkTractbasedSpatialStatisticsView::RemoveGroup()
{
QTableView *temp = static_cast<QTableView*>(m_Controls->m_GroupInfo);
QItemSelectionModel *selectionModel = temp->selectionModel();
QModelIndexList indices = selectionModel->selectedRows();
QModelIndex index;
foreach(index, indices)
{
int row = index.row();
m_GroupModel->removeRows(row, 1, QModelIndex());
}
示例13: setRightView
void MainWindow::setRightView()
{
QTableView *view = ui->m_rightTableInfo;
view->setModel(m_dirsContentsModel);
view->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
view->horizontalHeader()->resizeSection(0, 280); // 'Name' section. User can resize
view->horizontalHeader()->resizeSection(3, 130); // 'Type' section
connect(view, SIGNAL(activated(QModelIndex)),
view, SLOT(clearSelection())); // NOTE: must be the first connection
connect(view, SIGNAL(activated(QModelIndex)),
this, SLOT(slotSetLeftViewCurrentIndex(QModelIndex)));
connect(view, SIGNAL(activated(QModelIndex)),
this, SLOT(slotActivatedOnlyDirs(QModelIndex)));
connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(slotUpdateSelection(QItemSelection,QItemSelection)));
}
示例14: editEntry
//! [4a]
void AddressWidget::editEntry()
{
QTableView *temp = static_cast<QTableView*>(currentWidget());
QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(temp->model());
QItemSelectionModel *selectionModel = temp->selectionModel();
QModelIndexList indexes = selectionModel->selectedRows();
QString name;
QString address;
int row = -1;
foreach (QModelIndex index, indexes) {
row = proxy->mapToSource(index).row();
QModelIndex nameIndex = table->index(row, 0, QModelIndex());
QVariant varName = table->data(nameIndex, Qt::DisplayRole);
name = varName.toString();
QModelIndex addressIndex = table->index(row, 1, QModelIndex());
QVariant varAddr = table->data(addressIndex, Qt::DisplayRole);
address = varAddr.toString();
}
示例15: viewChanged
/** Called when switching between tabs
* @param index :: The index of the new active tab
*/
void MantidMatrix::viewChanged(int index) {
// get the previous view and selection model
QTableView *prevView = (QTableView *)m_tabs->widget(m_PrevIndex);
if (prevView) {
QItemSelectionModel *oldSelModel = prevView->selectionModel();
QItemSelectionModel *selModel = activeView()->selectionModel();
// Copy the selection from the previous tab into the newly-activated one
selModel->select(oldSelModel->selection(), QItemSelectionModel::Select);
// Clear the selection on the now-hidden tab
oldSelModel->clearSelection();
m_PrevIndex = index;
// get the previous tab scrollbar positions
int hValue = prevView->horizontalScrollBar()->value();
int vValue = prevView->verticalScrollBar()->value();
// to synchronize the views
// set the previous view scrollbar positions to current view
activeView()->horizontalScrollBar()->setValue(hValue);
activeView()->verticalScrollBar()->setValue(vValue);
}
}