本文整理汇总了C++中QTextTableFormat::clearColumnWidthConstraints方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableFormat::clearColumnWidthConstraints方法的具体用法?C++ QTextTableFormat::clearColumnWidthConstraints怎么用?C++ QTextTableFormat::clearColumnWidthConstraints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTableFormat
的用法示例。
在下文中一共展示了QTextTableFormat::clearColumnWidthConstraints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy
void QTextCopyHelper::copy()
{
if (cursor.hasComplexSelection()) {
QTextTable *table = cursor.currentTable();
int row_start, col_start, num_rows, num_cols;
cursor.selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
QTextTableFormat tableFormat = table->format();
tableFormat.setColumns(num_cols);
tableFormat.clearColumnWidthConstraints();
const int objectIndex = dst->formatCollection()->createObjectIndex(tableFormat);
Q_ASSERT(row_start != -1);
for (int r = row_start; r < row_start + num_rows; ++r) {
for (int c = col_start; c < col_start + num_cols; ++c) {
QTextTableCell cell = table->cellAt(r, c);
const int rspan = cell.rowSpan();
const int cspan = cell.columnSpan();
if (rspan != 1) {
int cr = cell.row();
if (cr != r)
continue;
}
if (cspan != 1) {
int cc = cell.column();
if (cc != c)
continue;
}
// add the QTextBeginningOfFrame
QTextCharFormat cellFormat = cell.format();
if (r + rspan >= row_start + num_rows) {
cellFormat.setTableCellRowSpan(row_start + num_rows - r);
}
if (c + cspan >= col_start + num_cols) {
cellFormat.setTableCellColumnSpan(col_start + num_cols - c);
}
const int charFormatIndex = convertFormatIndex(cellFormat, objectIndex);
int blockIdx = -2;
const int cellPos = cell.firstPosition();
QTextBlock block = src->blocksFind(cellPos);
if (block.position() == cellPos) {
blockIdx = convertFormatIndex(block.blockFormat());
}
dst->insertBlock(QTextBeginningOfFrame, insertPos, blockIdx, charFormatIndex);
++insertPos;
// nothing to add for empty cells
if (cell.lastPosition() > cellPos) {
// add the contents
appendFragments(cellPos, cell.lastPosition());
}
}
}
// add end of table
int end = table->lastPosition();
appendFragment(end, end+1, objectIndex);
} else {
appendFragments(cursor.selectionStart(), cursor.selectionEnd());
}
}