本文整理汇总了C++中QTableWidgetSelectionRange::rightColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableWidgetSelectionRange::rightColumn方法的具体用法?C++ QTableWidgetSelectionRange::rightColumn怎么用?C++ QTableWidgetSelectionRange::rightColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableWidgetSelectionRange
的用法示例。
在下文中一共展示了QTableWidgetSelectionRange::rightColumn方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: copy
//-----------------------------------------------------------------------------
void DatPanel::copy()
{
QTableWidgetSelectionRange ts = tab->selectedRanges().first();
register long i,j;
QString res, s;
for(j=ts.topRow();j<=ts.bottomRow();j++)
{
for(i=ts.leftColumn();i<=ts.rightColumn();i++)
{
res = res + tab->item(j,i)->text();
if(i<ts.rightColumn()) res = res + "\t";
}
res = res + "\n";
}
QApplication::clipboard()->setText(res, QClipboard::Clipboard);
}
示例4: 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);
}
示例5: 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;
}
示例6: 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));
}
}
示例7: sort
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);
}
}
示例8: 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);
}
示例9: clearSelection
void Matrix::clearSelection()
{
allow_modification_signals = false;
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++)
for(int j = cur.leftColumn(); j<= cur.rightColumn();j++)
setText(i, j, "");
}
allow_modification_signals = true;
emit modifiedWindow(this);
}
示例10: 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);
}
}
示例11: eventFilter
bool TableEventHandler::eventFilter(QObject *o, QEvent *e) {
if( !o ) qWarning("TableEventHandler::eventFilter called with 0 object?");
if( QString(o->metaObject()->className()) != tr("QTableWidget") ) {
#ifdef EI_DEBUG
qDebug("Only QTableWidget objects accepted! Returning!");
#endif
return false;
}
QTableWidget *to = (QTableWidget *)o;
if( e->type() == QEvent::KeyPress ) {
QKeyEvent *ke = (QKeyEvent*)e;
if(ke->matches(QKeySequence::Copy) ){
QString cellText; itemCopy.clear(); copyRange.clear();
QList<QTableWidgetSelectionRange> ts = to->selectedRanges();
if(!ts.isEmpty()) {
for ( int irow = ts.first().topRow(); irow <= ts.first().bottomRow(); irow++){
for ( int icol = ts.first().leftColumn(); icol <= ts.first().rightColumn(); icol++){
QTableWidgetItem *w = to->item(irow,icol);
if(w) cellText = w->text();
if ( !cellText.isEmpty() ){
itemCopy << cellText;
}
else
itemCopy << " ";
}
}
copyRange = ts;
//cout << itemCopy.join(", ").toLatin1().data() << endl;
}
else {
QTableWidgetItem *w = to->item(to->currentRow(), to->currentColumn());
if (w) cellText = w->text();
if ( !cellText.isEmpty() )
itemCopy << cellText;
else itemCopy << "";
}
return true;
}
else if(ke->matches(QKeySequence::Paste) && !itemCopy.isEmpty() && !copyRange.isEmpty()){
QList<QTableWidgetSelectionRange> cs = to->selectedRanges();
int top = cs.first().topRow(), left = cs.first().leftColumn(), icount = 0;
QTableWidgetSelectionRange ts = QTableWidgetSelectionRange(
top , left,
top + copyRange.first().rowCount()-1,
left + copyRange.first().columnCount()-1);
for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){
for ( int icol = ts.leftColumn(); icol <= ts.rightColumn(); icol++){
if ( ++icount <= itemCopy.size() )
to->setItem(irow, icol, new QTableWidgetItem(itemCopy[icount-1]));
}
}
return true;
}
else if(ke->matches(QKeySequence::Cut) ){
QString cellText; itemCopy.clear(); copyRange.clear();
QList<QTableWidgetSelectionRange> ts = to->selectedRanges();
if(!ts.isEmpty()) {
for (int irow = ts.first().topRow(); irow <= ts.first().bottomRow(); irow++) {
for(int icol = ts.first().leftColumn(); icol <= ts.first().rightColumn(); icol++) {
QTableWidgetItem *w = to->item(irow,icol);
if(w) cellText = w->text();
if ( !cellText.isEmpty() ){
itemCopy << cellText;
}
else
itemCopy << "";
to->setItem(irow,icol,0);
}
}
copyRange = ts;
//cout << itemCopy.join(", ").toLatin1().data() << endl;
}
return true;
}
else if(ke->matches(QKeySequence::Delete) ){
QList<QTableWidgetSelectionRange> ts = to->selectedRanges();
if(!ts.isEmpty()) {
for (int irow = ts.first().topRow(); irow <= ts.first().bottomRow(); irow++) {
for(int icol = ts.first().leftColumn(); icol <= ts.first().rightColumn(); icol++) {
to->setItem(irow,icol,0);
}
}
}
return true;
}
else
to->eventFilter(o, e);
}
return false;
}
示例12: pasteSelection
void Matrix::pasteSelection()
{
QString the_text = QApplication::clipboard()->text();
if (the_text.isEmpty())
return;
allow_modification_signals = false;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QTextStream ts( &the_text, QIODevice::ReadOnly );
QString s = ts.readLine();
QStringList cellTexts = s.split("\t");
int cols = cellTexts.count();
int rows = 1;
while(!ts.atEnd())
{
rows++;
s = ts.readLine();
}
ts.reset();
int i, j, top, bottom, right, left, firstCol;
QList<QTableWidgetSelectionRange> sel = d_table->selectedRanges();
QListIterator<QTableWidgetSelectionRange> it(sel);
QTableWidgetSelectionRange cur;
if (!sel.isEmpty())
{
cur = it.next();
top = cur.topRow();
bottom = cur.bottomRow();
left = cur.leftColumn();
right = cur.rightColumn();
}
else
{
top = 0;
bottom = numRows() - 1;
left = 0;
right = numCols() - 1;
firstCol = firstSelectedColumn();
if (firstCol >= 0)
{ // columns are selected
left = firstCol;
int selectedColsNumber = 0;
for(i=0; i<numCols(); i++)
{
if (isColumnSelected(i, true))
selectedColsNumber++;
}
right = firstCol + selectedColsNumber - 1;
}
}
QTextStream ts2( &the_text, QIODevice::ReadOnly );
int r = bottom-top+1;
int c = right-left+1;
QApplication::restoreOverrideCursor();
if (rows>r || cols>c)
{
// TODO: I find the insert cells option awkward
// I would prefer the behavior of OpenOffice Calc
// here - thzs
switch( QMessageBox::information(0,"QtiPlot",
tr("The text in the clipboard is larger than your current selection!\
\nDo you want to insert cells?"),
tr("Yes"), tr("No"), tr("Cancel"), 0, 0) )
{
case 0:
if(cols > c )
for(int i=0; i<(cols-c); i++)
d_table->insertColumn(left);
if(rows > r)
{
if (firstCol >= 0)
for(int i=0; i<(rows-r); i++)
d_table->insertRow(top);
else
for(int i=0; i<(rows-r+1); i++)
d_table->insertRow(top);
}
break;
case 1:
rows = r;
cols = c;
break;
case 2:
allow_modification_signals = true;
return;
break;
}
}
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
bool numeric;
//.........这里部分代码省略.........