本文整理汇总了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();
}
示例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();
}
示例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: 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();
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}