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


C++ QTableWidgetSelectionRange类代码示例

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


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

示例1: getItemText

QList<double> Calculator::extractData(const QStringList &stringArgs, const QList<double> &doubleArgs)
{
    QList<double> returnList;

    for (int i = 0; i < stringArgs.size(); i++)
    {
        int iterator = 0;

        if (isRange(stringArgs[i] + QChar(QChar::Null), iterator))
        {
            if (iterator == stringArgs[i].size()) //if there is only a range in the argument
            {
                QTableWidgetSelectionRange range;
                Table::decodeRange(stringArgs[i], range);

                for (int row=range.topRow(); row<=range.bottomRow(); row++)
                {
                    for (int column=range.leftColumn(); column<=range.rightColumn(); column++)
                    {
                        returnList.append(table -> getItemText(row, column).toDouble());
                    }
                }

                continue;
            }
        }

        returnList.append(doubleArgs[i]);
    }

    return returnList;
}
开发者ID:Iownnoname,项目名称:qt,代码行数:32,代码来源:Calculator.cpp

示例2: text

void Matrix::copySelection()
{
	QString the_text;
	QList<QTableWidgetSelectionRange> sel = d_table->selectedRanges();
	if (sel.isEmpty())
		the_text = text(d_table->currentRow(),d_table->currentColumn());
	else
	{
		QListIterator<QTableWidgetSelectionRange> it(sel);
		QTableWidgetSelectionRange cur;

		if(!it.hasNext())return;
		cur = it.next();

		int top = cur.topRow();
		int bottom = cur.bottomRow();
		int left = cur.leftColumn();
		int right = cur.rightColumn();
		for(int i=top; i<=bottom; i++)
		{
			for(int j=left; j<right; j++)
				the_text += text(i,j)+"\t";
			the_text += text(i,right)+"\n";
		}
	}

	// Copy text into the clipboard
	QApplication::clipboard()->setText(the_text);
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:29,代码来源:Matrix.cpp

示例3: tableSelectionChanged

void QueryPathsDialog::tableSelectionChanged()
{
    QList<QTableWidgetSelectionRange> selection = ui->tableWidget->selectedRanges();
    int totalSelectedRows = 0;
    for (int i = 0; i < selection.size(); ++i)
        totalSelectedRows += selection[i].rowCount();

    g_memory->queryPaths.clear();

    QList<int> selectedRows;
    for (int i = 0; i < selection.size(); ++i)
    {
        QTableWidgetSelectionRange * selectionRange = &(selection[i]);
        int top = selectionRange->topRow();
        int bottom = selectionRange->bottomRow();

        for (int row = top; row <= bottom; ++row)
        {
            if (!selectedRows.contains(row))
                selectedRows.push_back(row);
        }
    }

    for (int i = 0; i < selectedRows.size(); ++i)
    {
        int row = selectedRows[i];
        QString pathString = ui->tableWidget->item(row, 0)->text();
        QString pathStringFailure;
        g_memory->queryPaths.push_back(Path::makeFromString(pathString, false, &pathStringFailure));
    }

    emit selectionChanged();
}
开发者ID:BioinformaticsArchive,项目名称:Bandage,代码行数:33,代码来源:querypathsdialog.cpp

示例4: ss

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

示例5: qDebug

void ViewTableListWidget::showRightMenu( const QPoint & pos)
{

    //显示右键菜单
    qDebug()<<tr("视图菜单")<<pos.x()<<" "<<pos.y();

    QTableWidgetItem *curItem = this->itemAt(pos);



    if(curItem != NULL)
    {
        curindex = currentRow();
        viewfilenames.clear();
        QList<QTableWidgetSelectionRange> rangelist = this->selectedRanges();
        QList<QTableWidgetSelectionRange>::iterator iter = rangelist.begin();
        while(iter != rangelist.end())
        {
            QTableWidgetSelectionRange range = *iter;
            for(int i =range.topRow(); i<=range.bottomRow(); i++ )
                viewfilenames<<item(i,0)->text();
            ++iter;
        }
    }
    qDebug()<<viewfilenames;
    this->createRightMenu((int *)curItem);
}
开发者ID:nhosproject,项目名称:OSProject,代码行数:27,代码来源:viewtablelistwidget.cpp

示例6: dialog

void MainWindow::on_actionSort_triggered()
{
    SortDialog dialog(this);
    QTableWidgetSelectionRange range = spreadsheet->selectedRange();
    dialog.setColumnRange('A' + range.leftColumn(), 'A' + range.rightColumn());

    if(dialog.exec()){
        spreadsheet->sort(Compare(dialog));
    }
}
开发者ID:june3474,项目名称:spreadsheet,代码行数:10,代码来源:mainwindow.cpp

示例7: selectedRange

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

示例8: selectedRange

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

示例9:

static QTableWidgetItem *getSelectedRow(QTableWidget *tbl)
{
	QList<QTableWidgetSelectionRange> selections = tbl->selectedRanges();

	if(selections.size() != 1)
		return 0;

	QTableWidgetSelectionRange selection = selections.first();

	if(selection.rowCount() != 1)
		return 0;

	int row = selection.topRow();

	return tbl->item(row, 0);
}
开发者ID:BtbN,项目名称:btsync-qt,代码行数:16,代码来源:sharedfolderswidget.cpp

示例10: dialog

void MainWindow::sort()
{
	SortDialog  dialog(this);
	QTableWidgetSelectionRange range = spreadsheet->selectedRange();
	dialog.setColumnRange('A' + range.leftColumn(),'A'+range.rightColumn());
	if(dialog.exec())
	{
		SpreadsheetCompare compare;
		compare.keys[0]=dialog.primarycolumncombo->currentIndex();
		compare.keys[1]=dialog.sencondarycolumncombo->currentIndex() - 1;
		compare.keys[2]=dialog.tertiarycolumncombo->currentIndex() - 1;
		compare.ascending[0] = (dialog.primaryordercombo->currentIndex() ==0);
		compare.ascending[1] = (dialog.secondaryordercombo->currentIndex() == 0);
		compare.ascending[2] = (dialog.tertiaryordercombo->currentIndex() == 0);
		spreadsheet->sort(compare);
	}
}
开发者ID:houstar,项目名称:Qt,代码行数:17,代码来源:mainwindow.cpp

示例11: it

bool Matrix::rowsSelected()
{
	QList<QTableWidgetSelectionRange> sel = d_table->selectedRanges();
	QListIterator<QTableWidgetSelectionRange> it(sel);
	QTableWidgetSelectionRange cur;

	if( it.hasNext() )
	{
		cur = it.next();
		for(int i=cur.topRow(); i<=cur.bottomRow(); i++)
		{
			if (!isRowSelected (i, true))
				return false;
		}
	}
	return true;
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:17,代码来源:Matrix.cpp

示例12: selectedRanges

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

示例13: selectedRange

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

示例14: deleteMesh

void PMeshViewer::deleteMesh()
{
    QList<QTableWidgetSelectionRange> list = meshTable->selectedRanges();
    if (list.isEmpty())
        return;
        
    QTableWidgetSelectionRange range = list[0];  // Only 1 range.
    for (int i = range.bottomRow(); i >= range.topRow(); --i)
    {
        meshTable->removeRow(i);
        renderer->RemoveActor(meshList[i].actor);
        meshList[i].normals->Delete();
        meshList[i].mapper->Delete();
        meshList[i].actor->Delete();
        meshList.removeAt(i);
    }

    renderWindow->Render();
}
开发者ID:pLiuYang,项目名称:Anatomy-Annotator,代码行数:19,代码来源:PMeshViewer.cpp

示例15: copy

void TableWidget::copy()
{
	// Get a list of all selected ranges:
	QList<QTableWidgetSelectionRange> selectedRanges = this->selectedRanges();
	if(selectedRanges.isEmpty()) return;
	
	// Establish the outer boundary of all selections:
	int leftColumn  = this->columnCount() - 1;
	int rightColumn = 0;
	int topRow      = this->rowCount() - 1;
	int bottomRow   = 0;
	
	for(int i = 0; i < selectedRanges.size(); i++)
	{
		QTableWidgetSelectionRange range = selectedRanges.at(i);
		
		if(range.leftColumn()  < leftColumn)  leftColumn  = range.leftColumn();
		if(range.rightColumn() > rightColumn) rightColumn = range.rightColumn();
		if(range.topRow()      < topRow)      topRow      = range.topRow();
		if(range.bottomRow()   > bottomRow)   bottomRow   = range.bottomRow();
	}
	
	if(bottomRow < topRow or rightColumn < leftColumn) return;
	
	// Loop through selection range and extract data:
	QString outputText;
	
	for(int i = topRow; i <= bottomRow; i++)
	{
		for(int j = leftColumn; j <= rightColumn; j++)
		{
			if(this->item(i, j)->isSelected())
			{
				outputText += this->item(i, j)->text();
			}
			
			if (j < rightColumn) outputText += "\t";
			else                 outputText += "\n";
		}
	}
	
	// Copy data to clipboard:
	QClipboard *clipboard = QApplication::clipboard();
	clipboard->setText(outputText);
	
	return;
}
开发者ID:SoFiA-Admin,项目名称:SoFiA,代码行数:47,代码来源:TableWidget.cpp


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