本文整理汇总了C++中QTextTableFormat::rightMargin方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableFormat::rightMargin方法的具体用法?C++ QTextTableFormat::rightMargin怎么用?C++ QTextTableFormat::rightMargin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTableFormat
的用法示例。
在下文中一共展示了QTextTableFormat::rightMargin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layoutColumns
void KoTextLayoutTableArea::layoutColumns()
{
QTextTableFormat tableFormat = d->table->format();
d->columnPositions.resize(d->table->columns() + 1);
d->columnWidths.resize(d->table->columns() + 1);
// Table width.
d->tableWidth = 0;
qreal parentWidth = right() - left();
if (tableFormat.width().rawValue() == 0 || tableFormat.alignment() == Qt::AlignJustify) {
// We got a zero width value or alignment is justify, so use 100% of parent.
d->tableWidth = parentWidth - tableFormat.leftMargin() - tableFormat.rightMargin();
} else {
if (tableFormat.width().type() == QTextLength::FixedLength) {
// Fixed length value, so use the raw value directly.
d->tableWidth = tableFormat.width().rawValue();
} else if (tableFormat.width().type() == QTextLength::PercentageLength) {
// Percentage length value, so use a percentage of parent width.
d->tableWidth = tableFormat.width().rawValue() * (parentWidth / 100)
- tableFormat.leftMargin() - tableFormat.rightMargin();
} else {
// Unknown length type, so use 100% of parent.
d->tableWidth = parentWidth - tableFormat.leftMargin() - tableFormat.rightMargin();
}
}
// Column widths.
qreal availableWidth = d->tableWidth; // Width available for columns.
QList<int> fixedWidthColumns; // List of fixed width columns.
QList<int> relativeWidthColumns; // List of relative width columns.
qreal relativeWidthSum = 0; // Sum of relative column width values.
int numNonStyleColumns = 0;
for (int col = 0; col < d->table->columns(); ++col) {
KoTableColumnStyle columnStyle = d->carsManager.columnStyle(col);
if (columnStyle.hasProperty(KoTableColumnStyle::RelativeColumnWidth)) {
// Relative width specified. Will be handled in the next loop.
d->columnWidths[col] = 0.0;
relativeWidthColumns.append(col);
relativeWidthSum += columnStyle.relativeColumnWidth();
} else if (columnStyle.hasProperty(KoTableColumnStyle::ColumnWidth)) {
// Only width specified, so use it.
d->columnWidths[col] = columnStyle.columnWidth();
fixedWidthColumns.append(col);
availableWidth -= columnStyle.columnWidth();
} else {
// Neither width nor relative width specified.
d->columnWidths[col] = 0.0;
relativeWidthColumns.append(col); // handle it as a relative width column without asking for anything
++numNonStyleColumns;
}
}
// Handle the case that the fixed size columns are larger then the defined table width
if (availableWidth < 0.0) {
if (tableFormat.width().rawValue() == 0 && fixedWidthColumns.count() > 0) {
// If not table width was defined then we need to scale down the fixed size columns so they match
// into the width of the table.
qreal diff = (-availableWidth) / qreal(fixedWidthColumns.count());
foreach(int col, fixedWidthColumns) {
d->columnWidths[col] = qMax(qreal(0.0), d->columnWidths[col] - diff);
}
}