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


C++ QTableWidgetSelectionRange::columnCount方法代码示例

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


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

示例1: paste

void Spreadsheet::paste()
{
    QTableWidgetSelectionRange range = selectedRange();
    QString str = QApplication::clipboard()->text();
    QStringList rows = str.split('\n');
    int numRows = rows.count();
    int numColumns = rows.first().count('\t') + 1;

    if(     range.rowCount() * range.columnCount() != 1
        &&  (   range.rowCount() !=  numRows
             || range.columnCount() !=  numColumns)
      )
    {
        QMessageBox::information(this, tr("Spreadsheet")
                                 , tr("The information cannot be pasted because the copy"
                                      "and paste areas aren't the same size."));
        return;
    }

    for(int i = 0; i < numRows; ++i)
    {
        QStringList columns = rows[i].split('\t');
        for(int j = 0; j < numColumns; ++j)
        {
            int row = range.topRow() + i;
            int column = range.leftColumn() + j;
            if(row < RowCount && column < ColumnCount)
                setFormula(row, column, columns[j]);
        }
    }

    somethingChanged();
}
开发者ID:KleineKarsten,项目名称:CppGuiWithQt,代码行数:33,代码来源:spreadsheet.cpp

示例2: sort

void Spreadsheet::sort(const SpreadsheetCompare &compare)
{
    QList<QStringList> rows;
    QTableWidgetSelectionRange range = selectedRange();
    int i;

    for(i = 0; i < range.rowCount(); ++i)
    {
        QStringList row;
        for(int j = 0; j < range.columnCount(); ++j)
            row.append(formula(range.topRow() + i, range.leftColumn() + j));

        rows.append(row);
    }


    qStableSort(rows.begin(), rows.end(), compare);

    for(i = 0; i < range.rowCount(); ++i)
    {
        for(int j = 0; j < range.columnCount(); ++j)
            setFormula(range.topRow() + i, range.leftColumn() + j, rows[i][j]);
    }

    clearSelection();
    somethingChanged();
}
开发者ID:KleineKarsten,项目名称:CppGuiWithQt,代码行数:27,代码来源:spreadsheet.cpp

示例3: on_actionCopy_triggered

void MainWindow::on_actionCopy_triggered()
{
    QString str;
    QString s;
    QTextStream ss(&s);

    QList<QTableWidgetSelectionRange> ranges = ui->tableWidget->selectedRanges();

    if(ranges.isEmpty())
        return;

    QTableWidgetSelectionRange range =  ui->tableWidget->selectedRanges().first();
    for(int i=0; i<range.rowCount(); i++){
        if(i>0)
            str += '\n';
        for(int j=0; j<range.columnCount();j++){
            if(j>0)
                str+= "\t";
            if(j==1 && range.columnCount() == 3){
                ss << left << qSetFieldWidth(35) << ui->tableWidget->item(range.topRow()+i,range.leftColumn()+j)->text();
                str+=ui->tableWidget->item(range.topRow()+i,range.leftColumn()+j)->text();
            }
            else{
            ss << left << qSetFieldWidth(55) << ui->tableWidget->item(range.topRow()+i,range.leftColumn()+j)->text() << qSetFieldWidth(0);
            str+=ui->tableWidget->item(range.topRow()+i,range.leftColumn()+j)->text();}
        }
        ss << endl;
    }
    QApplication::clipboard()->setText(s);
   // qDebug() << str;
    //qDebug() << s;

}
开发者ID:Jyang772,项目名称:PenguHash,代码行数:33,代码来源:mainwindow.cpp

示例4: paste

void Spreadsheet::paste()
{
    QString str = QApplication::clipboard()->text();
    QStringList rows = str.split('\n');

    int numRows = rows.count();
    int numCols = rows.first().count('\t') + 1;

    QTableWidgetSelectionRange selection = selectedRange();
    if(selection.rowCount() * selection.columnCount() != 1 &&
            (numRows != selection.rowCount() || numCols != selection.columnCount())){
        QMessageBox::information(this, tr("Spreadsheet"),
                                 tr("The information cannot be paseted"
                                    "because the copy and the paste areas aren't the same size"));
        return;
    }

    int destRow = selection.topRow();
    int destCol = selection.leftColumn();

    for(int i=0; i<numRows; i++){
        QStringList columns = rows[i].split('\t');
        for(int j=0; j<numCols; j++){
            if(i+destRow < RowCount && j+destCol < ColumnCount)
                setFormula(i+destRow, j+destCol, columns[j]);
        }
    }

    somethingChanged();
}
开发者ID:june3474,项目名称:spreadsheet,代码行数:30,代码来源:spreadsheet.cpp

示例5: copyCells

void TableWidget::copyCells(){

    QList<QTableWidgetSelectionRange> ranges = selectedRanges();
    if(ranges.size()==0){
        return;
    }
    QTableWidgetSelectionRange range = ranges[0];
    QString str;
    for(int i=0; i<range.rowCount(); ++i) {
        if(i>0){
            str += "\n";
        }
        for(int j=0; j< range.columnCount(); ++j) {
            if(j>0){
                str += "\t";
            }
            if(!item(i,j)){
                str += "";
            }else{
                str += item(range.topRow() +i, range.leftColumn()+j)->text();
                qDebug()<<"adding to clipbard: "<<item(range.topRow() +i, range.leftColumn()+j)->text();
            }
        }
    }
    QApplication::clipboard()->setText(str);
}
开发者ID:ivareske,项目名称:TagEditor,代码行数:26,代码来源:TableWidget.cpp

示例6: paste

void TableWidget::paste(){

    QList<QTableWidgetSelectionRange> ranges = selectedRanges();
    if(ranges.size()==0){
        return;
    }
    QTableWidgetSelectionRange range = ranges[0];
    if(range.leftColumn()<TITLE || range.rightColumn()<TITLE){
        QMessageBox::information(this, tr("Discogs dialog"), tr("Pasting in the three first columns is not allowed") );
        return;
    }
    QString str = QApplication::clipboard()->text();
    qDebug()<<"clipboard: ";
    qDebug()<<str;
    QStringList rows = str.split('\n');
    int numRows = rows.count();
    int numColumns = rows.first().count('\t') + 1;
    if( range.rowCount() * range.columnCount() != 1
            && (range.rowCount() != numRows
                || range.columnCount() != numColumns)) {
        QMessageBox::information(this, tr("Discogs dialog"),
                                 tr("The information cannot be pasted because the copy "
                                    "and paste areas aren't the same size."));
        return;
    }
    bool enabled = isSortingEnabled();
    setSortingEnabled(false);
    for(int i=0; i<numRows; ++i) {
        QStringList columns = rows[i].split('\t');
        for(int j=0; j<numColumns; ++j) {
            int row = range.topRow() +i;
            int column = range.leftColumn() +j;
            if(row < rowCount() && column < columnCount()){
                if(!item(row,column)){
                    TableWidgetItem *item = new TableWidgetItem;
                    setItem(row,column,item);
                }
                item(row,column)->setText(columns[j]);
            }
        }
    }
    setSortingEnabled(enabled);
}
开发者ID:ivareske,项目名称:TagEditor,代码行数:43,代码来源:TableWidget.cpp

示例7: copySelectedRange

QString TrWidget::copySelectedRange(QTableWidgetSelectionRange range)
{
    QTableWidgetItem *item;
    QString str;
    qDebug() << "rowCount:" << range.rowCount();
    qDebug() << "columnCount:" << range.columnCount();
    for(int row = 0; row < range.rowCount(); row++)
    {
        if(row > 0){
            str += "\n";
        }
        for(int col = 0; col < range.columnCount(); col++)
        {
            if(col > 0) str += "\t";
            item = m_table->item(range.topRow() + row, range.leftColumn() + col);
            str += item->text();
        }
    }
    return str;
}
开发者ID:34985086,项目名称:QtTranslator,代码行数:20,代码来源:TrWidget.cpp

示例8: copy

void TransactionWidget::copy()
{
	QTableWidgetSelectionRange range = table->selectedRange();
	QString str;
	QString t;
	bool ok = false;

	for(int i = 0; i < range.rowCount(); i++)
	{
		for(int j = 0; j < range.columnCount(); j++)
		{
			if( table->isColumnHidden( range.leftColumn() + j ) )
				continue;

			t = table->text( range.topRow() + i, range.leftColumn() + j );
			if( j >= 2 && j <= 4 )
			{
				double d = t.toDouble(&ok);
				if( ok )
				{
					int conv = 0;
					if( j == 3 )
						conv = 3;
					else
						conv = 2;
					t = QString::number( d, 'f', conv );
				}
				//text = convertSumForDouble( text );
			}
			str += t;

			if( j < range.columnCount()-1 )
				str += "\t";
		}
		if( i < range.rowCount() - 1 )
			str += "\n";
	}

	QApplication::clipboard()->setText(str);
}
开发者ID:petrpopov,项目名称:db_transactions,代码行数:40,代码来源:transactionwidget.cpp

示例9: slotCopy

void TrWidget::slotCopy()
{
#if 0
    QList<QTableWidgetSelectionRange> ranges = m_table->selectedRanges();
    QString str;
    qDebug() << "slotCopy:" << ranges.size();
    for(int i = 0; i < ranges.size(); i++)
    {
        if(i > 0) str += "\n";
        str += copySelectedRange(ranges.at(i));
    }

    qDebug() << str;
    QApplication::clipboard()->setText(str);
#endif
    QString str;
    QTableWidgetItem *item;
    QTableWidgetSelectionRange range = selectedRange();
    qDebug() << "rowCount:" << range.rowCount();
    qDebug() << "columnCount:" << range.columnCount();
    for(int row = 0; row < range.rowCount(); row++)
    {
        if(row > 0){
            str += "\n";
        }
        for(int col = 0; col < range.columnCount(); col++)
        {
            if(col > 0) str += "\t";
            item = m_table->item(range.topRow() + row, range.leftColumn() + col);
            if(item->text().contains('\n')){
                str += QString("\"%1\"").arg(item->text());
            }else{
                str += item->text();
            }
        }
    }
    qDebug() << str;
    QApplication::clipboard()->setText(str);
}
开发者ID:34985086,项目名称:QtTranslator,代码行数:39,代码来源:TrWidget.cpp

示例10: copy

void OperationTable::copy()
{
	QTableWidgetSelectionRange range = selectedRange();
	QString str;

	for(int i = 0; i < range.rowCount(); i++)
	{
		for(int j = 0; j < range.columnCount(); j++)
		{
			if( isColumnHidden( range.leftColumn() + j ) )
				continue;

			str += this->text( range.topRow() + i, range.leftColumn() + j );
			if( j < range.columnCount()-1 )
				str += "\t";
		}
		if( i < range.rowCount() - 1 )
			str += "\n";
	}

	QApplication::clipboard()->setText(str);
}
开发者ID:petrpopov,项目名称:db_transactions,代码行数:22,代码来源:operationtable.cpp

示例11: paste

void UISpreadsheet::paste()
{
    QTableWidgetSelectionRange range = selectedRange();
    QString str = QApplication::clipboard()->text();
    QStringList rows = str.split('\n');
    int numRows = rows.count();
    int numColumns = rows.first().count('\t') + 1;
    cout<<str.toStdString()<<" to paste "<<endl;

    if (range.rowCount() * range.columnCount() != 1
            && (range.rowCount() != numRows
                || range.columnCount() != numColumns)) {
        QMessageBox::information(this, tr("Spreadsheet"),
                tr("The information cannot be pasted because the copy "
                   "and paste areas aren't the same size."));
        return;
    }

    cout<<"hola-------------------------------"<<endl;
    
    for (int i = 0; i < numRows; ++i) {
        QStringList columns = rows[i].split('\t');
       // cout<<"---"<<columns[0].toStdString();
      //  cout<<" tmb "<<columns[1].toStdString()<<endl;
        cout<<numRows<<"filas to copy"<<endl;
        for (int j = 0; j < numColumns; ++j) {
            int row = range.topRow() + i;
            cout<<"row"<<row<<endl;
            int column = range.leftColumn() + j;
            if (row < RowCount && column < ColumnCount)
              setFormula(row, column, columns[j]);
            //somethingChanged();
            //cout<<columns[j].toStdString()<<"should paste "<<row<<" "<<column<<endl;
        }
    }
  // somethingChanged();
}
开发者ID:CS-UNSA,项目名称:CS102O-AlisonTorresAguilar-EdwinCornejoMayta,代码行数:37,代码来源:uispreadsheet.cpp

示例12: copy

void Spreadsheet::copy()
{
    QTableWidgetSelectionRange range = selectedRange();
    QString str;

    for (int i = 0; i < range.rowCount(); ++i) {
        if (i > 0)
            str += "\n";
        for (int j = 0; j < range.columnCount(); ++j) {
            if (j > 0)
                str += "\t";
            str += formula(range.topRow() + i, range.leftColumn() + j);
        }
    }
    QApplication::clipboard()->setText(str);
}
开发者ID:bwarfield,项目名称:WarfieldBrian_CIS17B_48941,代码行数:16,代码来源:spreadsheet.cpp

示例13: copy

void Spreadsheet::copy()
{
    QTableWidgetSelectionRange selection = selectedRange();
    QString str;

    int numRows = selection.rowCount();
    int numCols = selection.columnCount();

    for(int i=0; i<numRows; i++){
        for(int j=0; j<numCols; j++){
            str += formula(selection.topRow()+i, selection.leftColumn()+j);
            if(j+1 != numCols)
                str += "\t";
        }
        if(i+1 != numRows)
            str += "\n";
    }

    QApplication::clipboard()->setText(str);
}
开发者ID:june3474,项目名称:spreadsheet,代码行数:20,代码来源:spreadsheet.cpp


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