本文整理汇总了C++中QTableWidgetSelectionRange::leftColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableWidgetSelectionRange::leftColumn方法的具体用法?C++ QTableWidgetSelectionRange::leftColumn怎么用?C++ QTableWidgetSelectionRange::leftColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableWidgetSelectionRange
的用法示例。
在下文中一共展示了QTableWidgetSelectionRange::leftColumn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: isColumnSelected
bool Matrix::isColumnSelected(int col, bool full)
{
QList<QTableWidgetSelectionRange> sel = d_table->selectedRanges();
QListIterator<QTableWidgetSelectionRange> it(sel);
QTableWidgetSelectionRange cur;
if ( !full )
{
if( it.hasNext() )
{
cur = it.next();
if ( (col >= cur.leftColumn()) && (col <= cur.rightColumn() ) )
return true;
}
}
else
{
if( it.hasNext() )
{
cur = it.next();
if ( col >= cur.leftColumn() &&
col <= cur.rightColumn() &&
cur.topRow() == 0 &&
cur.bottomRow() == numRows() - 1 )
return true;
}
}
return false;
}
示例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;
}
示例4: 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();
}
示例5: 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();
}
示例6: copySelection
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);
}
示例7: 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();
}
示例8: 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;
}
示例9: 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;
}
示例10: 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);
}
示例11: on_actionSort_triggered
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));
}
}
示例12: duplicateDownSelection
void TreeSubWindow::duplicateDownSelection(unsigned int rep)
{
QList<QTableWidgetSelectionRange> selection = nodeEditor_->selectedRanges();
if (selection.size() == 0) {
QMessageBox::critical(phyview_, QString("Oups..."), QString("No selection."));
return;
}
//Perform some checking:
int row = -1;
for (int i = 0; i < selection.size(); ++i) {
QTableWidgetSelectionRange range = selection[i];
if (range.rowCount() != 1) {
QMessageBox::critical(phyview_, QString("Oups..."), QString("Only one row can be selected."));
return;
}
if (i == 0) {
row = range.topRow();
} else {
if (range.topRow() != row) {
QMessageBox::critical(phyview_, QString("Oups..."), QString("Only one row can be selected."));
return;
}
}
}
//Ok, if we reach this stage, then everything is ok...
int j;
for (j = row + 1; j < nodeEditor_->rowCount() && j - row <= static_cast<int>(rep); ++j) {
for (int i = 0; i < selection.size(); ++i) {
QTableWidgetSelectionRange range = selection[i];
for (int k = range.leftColumn(); k <= range.rightColumn(); ++k) {
nodeEditor_->setItem(j, k, nodeEditor_->item(row, k)->clone());
}
}
}
//Shift selection:
for (int i = 0; i < selection.size(); ++i) {
QTableWidgetSelectionRange range = selection[i];
nodeEditor_->setRangeSelected(range, false);
nodeEditor_->setRangeSelected(QTableWidgetSelectionRange(j - 1, range.leftColumn(), j - 1, range.rightColumn()), true);
}
}
示例13: 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);
}
示例14: 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);
}
示例15: 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);
}