当前位置: 首页>>代码示例>>C++>>正文


C++ QTableView类代码示例

本文整理汇总了C++中QTableView的典型用法代码示例。如果您正苦于以下问题:C++ QTableView类的具体用法?C++ QTableView怎么用?C++ QTableView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QTableView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
    }
}
开发者ID:GregoryBetz,项目名称:syscoin2,代码行数:22,代码来源:mycertlistpage.cpp

示例2: 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);
    }
}
开发者ID:coinkeeper,项目名称:2015-06-22_18-54_nubits,代码行数:39,代码来源:addressbookpage.cpp

示例3: 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();
    QModelIndex index, i;        
    QString name;
    QString address;
    int row = -1;

    foreach (index, indexes) {
        row = proxy->mapToSource(index).row();
        i = table->index(row, 0, QModelIndex());
        QVariant varName = table->data(i, Qt::DisplayRole);
        name = varName.toString();
    
        i = table->index(row, 1, QModelIndex());
        QVariant varAddr = table->data(i, Qt::DisplayRole);
        address = varAddr.toString();
    }
开发者ID:Andreas665,项目名称:qt,代码行数:23,代码来源:addresswidget.cpp

示例4: QString

void MainWindow::on_actShowStat_triggered()
{
  QString query = QString("call p_showStat_admin('%1', '%2', 0);")
      .arg(_model->dateA_dbformat())
      .arg(_model->dateZ_dbformat());
  qDebug() << query;
  QSqlQueryModel *m = App::theApp()->db_model(query);

  QDialog *dlgStat = new QDialog();
  dlgStat->setWindowTitle("Статистика");
  dlgStat->setGeometry(200, 200, 400, 200);

  QTableView* view = new QTableView();
  view->setModel(m);
  view->resizeColumnsToContents();
  view->resizeRowsToContents();

  QVBoxLayout* lay = new QVBoxLayout(dlgStat);
  lay->addWidget(view);

  dlgStat->exec();
}
开发者ID:nektuty,项目名称:orders-admin,代码行数:22,代码来源:mainwindow.cpp

示例5: setupViews

void MainWindow::setupViews()
{
    QSplitter *splitter = new QSplitter;
    QTableView *table = new QTableView;
    pieChart = new PieView;
    splitter->addWidget(table);
    splitter->addWidget(pieChart);
    splitter->setStretchFactor(0, 0);
    splitter->setStretchFactor(1, 1);

    table->setModel(model);
    pieChart->setModel(model);

    QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
    table->setSelectionModel(selectionModel);
    pieChart->setSelectionModel(selectionModel);

    QHeaderView *headerView = table->horizontalHeader();
    headerView->setStretchLastSection(true);

    setCentralWidget(splitter);
}
开发者ID:paspeur,项目名称:ev3sources,代码行数:22,代码来源:mainwindow.cpp

示例6: do_copyPathName_Clipboard

void MainWindow::do_copyPathName_Clipboard()
{
    QTableView *tab = ui->tableView_result;
    QString t;

    QItemSelectionModel *selections = tab->selectionModel();
    QList<QModelIndex> list= selections->selectedRows();
    for(int i=0; i<list.size(); i++)
    {
        //修改时间
        QString filename=
                modelResult->item(list.at(i).row(),1)->text().trimmed()
                +QDir::separator()
                +modelResult->item(list.at(i).row(),0)->text().trimmed();
        t += tr("文件名:") + filename + tr("\n");
        //行号信息
        QString lineno = modelResult->item(list.at(i).row(),2)->text().trimmed();
        if(!lineno.isEmpty())
        {
            t += tr("行号:") + lineno + tr("\n");
        }
        //行内容
        QString linestr = modelResult->item(list.at(i).row(),3)->text().trimmed();
        if(!linestr.isEmpty())
        {
            t += tr("行内容:") + linestr + tr("\n");
        }
        //修改时间
        QString modftime = modelResult->item(list.at(i).row(),4)->text().trimmed();
        if(!modftime.isEmpty())
        {
            t += tr("修改时间:") + modftime + tr("\n");
        }
        //换行
        t += "\n\n";
    }
    QClipboard *board = QApplication::clipboard();
    board->setText(t);
}
开发者ID:lovekernel,项目名称:pingpingsearch,代码行数:39,代码来源:mainwindow.cpp

示例7: 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);
}
开发者ID:Misriyadi,项目名称:Batamcoin,代码行数:22,代码来源:addressbookpage.cpp

示例8: AbstractAnalysisWidget

/*! Constructor */
StateBasedPhiWidget::StateBasedPhiWidget(QWidget *parent) : AbstractAnalysisWidget(parent){
	QVBoxLayout *mainVerticalBox = new QVBoxLayout(this);

	//Create a state based phi analysis dao to be used by this class
	stateDao = new StateBasedPhiAnalysisDao(Globals::getAnalysisDao()->getDBInfo());

	//Initialize analysis parameters and other variables
	initializeAnalysisInfo();

	//Set up analysis runner with function to create threads to analyze for state-based phi
	analysisRunner->setTimeStepThreadCreationFunction(&createAnalysisTimeStepThread);

	//Add tool bar to top of widget
	toolBar = getDefaultToolBar();
	checkToolBarEnabled();//Can only carry out analysis if a network and archive are loaded
	mainVerticalBox->addWidget(toolBar);

	//Create a tabbed widget to hold progress and results
	QTabWidget* tabWidget = new QTabWidget(this);

	//Add the model and view displaying the current analysis
	fullResultsModel = new FullResultsModel(&analysisInfo, stateDao);
	QTableView* fullResultsTableView = new FullResultsTableView(this, fullResultsModel);
	fullResultsTableView->setMinimumSize(500, 500);
	tabWidget->addTab(fullResultsTableView, "Results");

	//Add widget displaying progress
	progressWidget = new ProgressWidget(this);
	connect(analysisRunner, SIGNAL(progress(const QString&, unsigned int, unsigned int, unsigned int)), progressWidget, SLOT(updateProgress(const QString&, unsigned int, unsigned int, unsigned int)), Qt::QueuedConnection);
	connect(analysisRunner, SIGNAL(timeStepComplete(unsigned int)), progressWidget, SLOT(timeStepComplete(unsigned int)), Qt::QueuedConnection);
	progressWidget->setMinimumSize(500, 500);
	QScrollArea* progressScrollArea = new QScrollArea(this);
	progressScrollArea->setWidget(progressWidget);
	tabWidget->addTab(progressScrollArea, "Progress");
	mainVerticalBox->addWidget(tabWidget);

	mainVerticalBox->addStretch(5);
}
开发者ID:nico202,项目名称:spikestream,代码行数:39,代码来源:StateBasedPhiWidget.cpp

示例9: 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);
        }
开发者ID:JoshuaAmsden,项目名称:bicreditsnew,代码行数:38,代码来源:invoicepage.cpp

示例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;
        }
    }

}
开发者ID:Meee32,项目名称:net2,代码行数:23,代码来源:shoppingpage.cpp

示例11: main

int main(int argc, char ** argv)
{
	std::vector<test_entity> data =
	{
	    {"first", 1},
	    {"second", 2},
	    {"opla", 3},
	    {"123", 4},
	};

	test_model model;

	QApplication qapp {argc, argv};

	QTableView view;
	view.setModel(&model);

	view.show();

	model.assign(std::move(data));

	return qapp.exec();
}
开发者ID:dmlys,项目名称:QtTools,代码行数:23,代码来源:main.cpp

示例12: main

int main(int argc, char ** argv) {
    QApplication app{argc, argv};
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(":memory:");
    if (! db.open()) return 1;
    db.exec("create table example (name text, inuse numeric);");
    db.exec("insert into example (name, inuse) values "
            "('Zaphod', 0), ('Beeblebrox', 1);");

    QSqlTableModel model;
    model.setTable("example");
    model.select();

    BoolProxy proxy{1};
    proxy.setSourceModel(&model);

    QTableView ui;
    YesNoDelegate delegate;
    ui.setItemDelegateForColumn(1, &delegate);
    ui.setModel(&proxy);
    ui.show();
    return app.exec();
}
开发者ID:KubaO,项目名称:stackoverflown,代码行数:23,代码来源:main.cpp

示例13: on_pushButton_clicked

void MainWindow::on_pushButton_clicked()
{
    int current_tab = this->ui->tabWidget->currentIndex();

    QPrinter printer;
    QTableView *myWidget;

    switch(current_tab)
    {
    case TABLE::StudentsTableTab:
        myWidget = this->ui->StudentsTableView;
        break;

    case TABLE::TeachersTableTab:
        myWidget = this->ui->TeachersTableView;
        break;
    default:
        return;
    }

    QPixmap pix = myWidget->grab();
    QPainter painter;
    printer.setResolution(QPrinter::HighResolution);

    printer.setPageMargins (15,15,15,15,QPrinter::Millimeter);
    painter.begin(&printer);
    double xscale = printer.pageRect().width()/double(myWidget->width() + 50);
    double yscale = printer.pageRect().height()/double(myWidget->height() + 50);
    double scale = qMin(xscale, yscale);
    painter.scale(scale, scale);

    painter.drawPixmap(0, 0, pix);
    painter.end();

    myWidget->render(&painter);

}
开发者ID:kolur20,项目名称:DataBaseStudents,代码行数:37,代码来源:mainwindow.cpp

示例14: KFilterEffectConfigWidgetBase

ColorMatrixEffectConfigWidget::ColorMatrixEffectConfigWidget(QWidget *parent)
        : KFilterEffectConfigWidgetBase(parent), m_effect(0)
{
    QGridLayout * g = new QGridLayout(this);

    m_type = new KComboBox(this);
    m_type->addItem(i18n("Apply color matrix"));
    m_type->addItem(i18n("Saturate colors"));
    m_type->addItem(i18n("Rotate hue"));
    m_type->addItem(i18n("Luminance to alpha"));
    g->addWidget(m_type, 0, 0);

    m_stack = new QStackedWidget(this);
    m_stack->setContentsMargins(0, 0, 0, 0);
    g->addWidget(m_stack, 1, 0);

    m_matrixModel = new MatrixDataModel(this);

    QTableView * matrixWidget = new QTableView(m_stack);
    matrixWidget->setModel(m_matrixModel);
    matrixWidget->horizontalHeader()->hide();
    matrixWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    matrixWidget->verticalHeader()->hide();
    matrixWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    m_stack->addWidget(matrixWidget);

    QWidget * saturateWidget = new QWidget(m_stack);
    QGridLayout * saturateLayout = new QGridLayout(saturateWidget);
    saturateLayout->addWidget(new QLabel(i18n("Saturate value"), saturateWidget), 0, 0);
    m_saturate = new KDoubleNumInput(saturateWidget);
    m_saturate->setRange(0.0, 1.0, 0.05, false);
    saturateLayout->addWidget(m_saturate, 0, 1);
    saturateLayout->addItem(new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 1, 0);
    saturateWidget->setLayout(saturateLayout);
    m_stack->addWidget(saturateWidget);

    QWidget * hueRotateWidget = new QWidget(m_stack);
    QGridLayout * hueRotateLayout = new QGridLayout(hueRotateWidget);
    hueRotateLayout->addWidget(new QLabel(i18n("Angle"), hueRotateWidget), 0, 0);
    m_hueRotate = new KDoubleNumInput(hueRotateWidget);
    m_hueRotate->setRange(0.0, 360.0, 1.0, false);
    hueRotateLayout->addWidget(m_hueRotate, 0, 1);
    hueRotateLayout->addItem(new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 1, 0);
    hueRotateWidget->setLayout(hueRotateLayout);
    m_stack->addWidget(hueRotateWidget);

    QWidget * luminanceWidget = new QWidget(m_stack);
    m_stack->addWidget(luminanceWidget);

    setLayout(g);

    connect(m_type, SIGNAL(currentIndexChanged(int)), m_stack, SLOT(setCurrentIndex(int)));
    connect(m_type, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged(int)));
    connect(m_saturate, SIGNAL(valueChanged(double)), this, SLOT(saturateChanged(double)));
    connect(m_hueRotate, SIGNAL(valueChanged(double)), this, SLOT(hueRotateChanged(double)));
    connect(m_matrixModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(matrixChanged()));
}
开发者ID:KDE,项目名称:koffice,代码行数:57,代码来源:ColorMatrixEffectConfigWidget.cpp

示例15: QMainWindow

QtTutorial::QtTutorial(QWidget *parent)
	: QMainWindow(parent)
{
	QTableView *tableView = new QTableView();
	tableView->show();

	QTableView *tableView2 = new QTableView();
	tableView2->show();

	// RGBA
	QColor red = QColor(255, 0, 0, 255);
	QColor green = QColor(0, 255, 0, 255);
	QColor blue = QColor(0, 0, 255, 255);
	QColor grey = QColor(155, 155, 155, 255);

	QList<QColor> colors;
	colors.append(red);
	colors.append(green);
	colors.append(blue);
	colors.append(grey);

	QList<QList<QColor>> items;
	for(int i = 0; i < 5; i++)
	{
		items.append(colors);
	}

	PaletteTableModel *model = new PaletteTableModel(items);
	tableView->setModel(model);
	tableView2->setModel(model);

	//model->removeColumns(1, 1);
	//model->removeRows(0,1);

	//model->insertRows(0, 5);
	//model->insertColumns(0, 2);
}
开发者ID:Brenndoerfer,项目名称:Tutorial,代码行数:37,代码来源:QtTutorial.cpp


注:本文中的QTableView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。