本文整理汇总了C++中QTextTableFormat::setBorderBrush方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableFormat::setBorderBrush方法的具体用法?C++ QTextTableFormat::setBorderBrush怎么用?C++ QTextTableFormat::setBorderBrush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTableFormat
的用法示例。
在下文中一共展示了QTextTableFormat::setBorderBrush方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QTextLength
void KDReports::AbstractTableElement::fillTableFormat( QTextTableFormat& tableFormat, QTextCursor& textDocCursor ) const
{
if ( d->m_width ) {
if ( d->m_unit == Millimeters ) {
tableFormat.setWidth( QTextLength( QTextLength::FixedLength, mmToPixels( d->m_width ) ) );
} else {
tableFormat.setWidth( QTextLength( QTextLength::PercentageLength, d->m_width ) );
}
}
tableFormat.setBorder( border() );
#if QT_VERSION >= 0x040300
tableFormat.setBorderBrush( borderBrush() );
tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid );
#endif
tableFormat.setCellPadding( mmToPixels( padding() ) );
tableFormat.setCellSpacing( -1 ); // HTML-like table borders look so old century
if ( d->m_fontSpecified ) {
QTextCharFormat charFormat = textDocCursor.charFormat();
charFormat.setFont( d->m_defaultFont );
textDocCursor.setCharFormat( charFormat );
}
}
示例2: createPages
void KWQTableView::createPages(QPrinter *printer, QTextDocument *textDoc, bool sendToPrinter)
{
printer->setFullPage(true);
int myDpi = printer->logicalDpiY();
if (Prefs::printStyle() == Prefs::EnumPrintStyle::Flashcard) {
printer->setOrientation(QPrinter::Landscape);
int cardWidth = qRound(5 * qreal(myDpi));
int cardHeight = qRound(3 * qreal(myDpi));
QTextTable *table = textDoc->rootFrame()->lastCursorPosition().insertTable(model()->rowCount(), 2);
QTextTableFormat tableFormat = table->format();
tableFormat.setHeaderRowCount(0);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_None);
tableFormat.setCellSpacing(0);
tableFormat.setCellPadding(0);
QVector<QTextLength> constraints;
constraints.append(QTextLength(QTextLength::FixedLength, cardWidth));
constraints.append(QTextLength(QTextLength::FixedLength, cardWidth));
tableFormat.setColumnWidthConstraints(constraints);
table->setFormat(tableFormat);
QTextBlockFormat headerFormat;
headerFormat.setAlignment(Qt::AlignLeft);
QTextCharFormat headerCharFormat;
headerCharFormat.setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
QTextBlockFormat cellFormat;
cellFormat.setAlignment(Qt::AlignCenter);
QTextCharFormat cellCharFormat;
cellCharFormat.setFont(Prefs::editorFont());
QTextFrameFormat cardFormat;
cardFormat.setBorder(1);
cardFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
cardFormat.setBorderBrush(QBrush(Qt::black));
cardFormat.setWidth(QTextLength(QTextLength::FixedLength, cardWidth));
cardFormat.setHeight(QTextLength(QTextLength::FixedLength, cardHeight));
cardFormat.setPadding(qRound(0.25 * myDpi));
QTextFrameFormat lineFormat;
lineFormat.setBorder(1);
lineFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
lineFormat.setBorderBrush(QBrush(Qt::black));
lineFormat.setWidth(QTextLength(QTextLength::FixedLength, qRound(4.5 * myDpi)));
lineFormat.setHeight(1.1); //1 is drawn as a box whereas this is drawn as a line. Strange...
lineFormat.setPadding(0);
QTextFrame *card;
for (int i = 0; i < model()->rowCount(); i++) {
for (int j = 0; j < model()->columnCount(); j++) {
cardFormat.setPosition(QTextFrameFormat::FloatLeft);
card = table->cellAt(i, j).firstCursorPosition().insertFrame(cardFormat);
card->lastCursorPosition().insertText(model()->headerData(j, Qt::Horizontal, Qt::DisplayRole).toString(), headerCharFormat);
card->lastCursorPosition().insertFrame(lineFormat);
card->lastCursorPosition().insertBlock();
card->lastCursorPosition().insertBlock();
card->lastCursorPosition().insertBlock(cellFormat, cellCharFormat);
card->lastCursorPosition().insertText(model()->data(model()->index(i, j)).toString(), cellCharFormat);
}
}
}
else
{
textDoc->rootFrame()->lastCursorPosition().insertText(QStringLiteral("kwordquiz %1").arg(KWQ_VERSION));
if (Prefs::printStyle() == Prefs::EnumPrintStyle::Exam)
textDoc->rootFrame()->lastCursorPosition().insertText(' ' + i18n("Name:_____________________________ Date:__________"));
QTextTable* table;
if (Prefs::printStyle() == Prefs::EnumPrintStyle::Exam)
table = textDoc->rootFrame()->lastCursorPosition().insertTable(model()->rowCount() + 1, model()->columnCount() + 2);
else
table = textDoc->rootFrame()->lastCursorPosition().insertTable(model()->rowCount() + 1, model()->columnCount() + 1);
QTextTableFormat tableFormat = table->format();
tableFormat.setHeaderRowCount(1);
tableFormat.setBorder(1);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
tableFormat.setCellSpacing(0);
tableFormat.setBorderBrush(QBrush(Qt::black));
tableFormat.setCellPadding(2);
QVector<QTextLength> constraints;
constraints.append(QTextLength(QTextLength::FixedLength, verticalHeader()->width()));
constraints.append(QTextLength(QTextLength::FixedLength, columnWidth(0)));
constraints.append(QTextLength(QTextLength::FixedLength, columnWidth(1)));
if (Prefs::printStyle() == Prefs::EnumPrintStyle::Exam)
constraints.append(QTextLength(QTextLength::FixedLength, 50));
tableFormat.setColumnWidthConstraints(constraints);
table->setFormat(tableFormat);
QTextBlockFormat headerFormat;
//.........这里部分代码省略.........
示例3: draw
void CDiaryEdit::draw(QTextDocument& doc)
{
CDiaryEditLock lock(this);
QFontMetrics fm(QFont(font().family(),10));
bool hasGeoCaches = false;
int cnt;
int w = doc.textWidth();
int pointSize = ((10 * (w - 2 * ROOT_FRAME_MARGIN)) / (CHAR_PER_LINE * fm.width("X")));
if(pointSize == 0) return;
doc.setUndoRedoEnabled(false);
QFont f = textEdit->font();
f.setPointSize(pointSize);
textEdit->setFont(f);
QTextCharFormat fmtCharHeading1;
fmtCharHeading1.setFont(f);
fmtCharHeading1.setFontWeight(QFont::Black);
fmtCharHeading1.setFontPointSize(f.pointSize() + 8);
QTextCharFormat fmtCharHeading2;
fmtCharHeading2.setFont(f);
fmtCharHeading2.setFontWeight(QFont::Black);
fmtCharHeading2.setFontPointSize(f.pointSize() + 4);
QTextCharFormat fmtCharStandard;
fmtCharStandard.setFont(f);
QTextCharFormat fmtCharHeader;
fmtCharHeader.setFont(f);
fmtCharHeader.setBackground(Qt::darkBlue);
fmtCharHeader.setFontWeight(QFont::Bold);
fmtCharHeader.setForeground(Qt::white);
QTextBlockFormat fmtBlockStandard;
fmtBlockStandard.setTopMargin(10);
fmtBlockStandard.setBottomMargin(10);
fmtBlockStandard.setAlignment(Qt::AlignJustify);
QTextFrameFormat fmtFrameStandard;
fmtFrameStandard.setTopMargin(5);
fmtFrameStandard.setBottomMargin(5);
fmtFrameStandard.setWidth(w - 2 * ROOT_FRAME_MARGIN);
QTextFrameFormat fmtFrameRoot;
fmtFrameRoot.setTopMargin(ROOT_FRAME_MARGIN);
fmtFrameRoot.setBottomMargin(ROOT_FRAME_MARGIN);
fmtFrameRoot.setLeftMargin(ROOT_FRAME_MARGIN);
fmtFrameRoot.setRightMargin(ROOT_FRAME_MARGIN);
QTextTableFormat fmtTableStandard;
fmtTableStandard.setBorder(1);
fmtTableStandard.setBorderBrush(Qt::black);
fmtTableStandard.setCellPadding(4);
fmtTableStandard.setCellSpacing(0);
fmtTableStandard.setHeaderRowCount(1);
fmtTableStandard.setTopMargin(10);
fmtTableStandard.setBottomMargin(20);
fmtTableStandard.setWidth(w - 2 * ROOT_FRAME_MARGIN);
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::FixedLength, 32);
constraints << QTextLength(QTextLength::VariableLength, 50);
constraints << QTextLength(QTextLength::VariableLength, 100);
fmtTableStandard.setColumnWidthConstraints(constraints);
doc.rootFrame()->setFrameFormat(fmtFrameRoot);
QTextCursor cursor = doc.rootFrame()->firstCursorPosition();
cursor.insertText(diary.getName(), fmtCharHeading1);
cursor.setCharFormat(fmtCharStandard);
cursor.setBlockFormat(fmtBlockStandard);
diary.diaryFrame = cursor.insertFrame(fmtFrameStandard);
{
QTextCursor cursor1(diary.diaryFrame);
cursor1.setCharFormat(fmtCharStandard);
cursor1.setBlockFormat(fmtBlockStandard);
if(diary.getComment().isEmpty())
{
cursor1.insertText(tr("Add your own text here..."));
}
else
{
cursor1.insertHtml(diary.getComment());
}
cursor.setPosition(cursor1.position()+1);
}
if(!diary.getWpts().isEmpty())
{
QList<CWpt*>& wpts = diary.getWpts();
cursor.insertText(tr("Waypoints"),fmtCharHeading2);
QTextTable * table = cursor.insertTable(wpts.count()+1, eMax, fmtTableStandard);
//.........这里部分代码省略.........
示例4: printCalc
void CalcFrame::printCalc()
{
const auto milkReception = m_mainWindow->database()->milkReception();
if (!milkReception) {
Utils::Main::showMsgIfDbNotChoosed(this);
return;
}
DataWorker dw(m_mainWindow->database());
try {
dw.loadMilkReceptions(getWhereQuery());
} catch (const QString &err) {
QMessageBox::critical(this, tr("Расчеты"), tr("Произошла ошибка во время подгрузки данных: ") + err);
}
const auto deliverers = dw.getDeliverers().values();
if (deliverers.isEmpty())
{
QMessageBox::information(this, tr("Печать"), tr("Отсутствуют данные для печати"));
return;
}
const char f = 'f';
int row = 0;
const auto settings = m_mainWindow->getSettings();
const auto printColumns = m_mainWindow->getSettings()->getPrint().columns;
QStringList columns;
for (int i = 0; i < printColumns.size(); ++i) {
const auto &col = printColumns[i];
if (col.isShow)
columns.append(printColumns[i].display);
}
const int columnsCount = columns.size();
if (columnsCount <= 0) {
QMessageBox::information(this, tr("Печать сдачи молока"), tr("Не выбрана ни одна колонка для печати"));
return;
}
const Settings::Column snCol = printColumns[Constants::PrintColumns::SerialNumber],
delivNameCol = printColumns[Constants::PrintColumns::DeliverersName],
litersCol = printColumns[Constants::PrintColumns::Liters],
fatCol = printColumns[Constants::PrintColumns::Fat],
proteinCol = printColumns[Constants::PrintColumns::Protein],
fatUnitsCol = printColumns[Constants::PrintColumns::FatUnits],
rankWeightCol = printColumns[Constants::PrintColumns::RankWeight],
payCol = printColumns[Constants::PrintColumns::PayWithOutPrem],
permiumCol = printColumns[Constants::PrintColumns::Premium],
sumCol = printColumns[Constants::PrintColumns::Sum],
signCol = printColumns[Constants::PrintColumns::Sign];
auto itemToPrintRow = [&](const QString &delivName, const CalculatedItem::Data &item,
const int rowPos = -1) -> QStringList
{
QStringList row;
if (snCol.isShow)
row.append(rowPos >= 0 ? QString::number(rowPos) : QString());
if (delivNameCol.isShow)
row.append(delivName);
if (litersCol.isShow)
row.append(QString::number(item.liters, f, litersCol.prec));
if (fatCol.isShow)
row.append(QString::number(item.fat, f, fatCol.prec));
if (proteinCol.isShow)
row.append(QString::number(item.protein, f, proteinCol.prec));
if (fatUnitsCol.isShow)
row.append(QString::number(item.fatUnits, f, fatCol.prec));
if (rankWeightCol.isShow)
row.append(QString::number(item.rankWeight, f, rankWeightCol.prec));
if (payCol.isShow)
row.append(QString::number(item.paymentWithOutPremium, f, payCol.prec));
if (permiumCol.isShow)
row.append(QString::number(item.premiumForFat, f, permiumCol.prec));
if (sumCol.isShow)
row.append(QString::number(floor(item.sum), f, sumCol.prec));
if (signCol.isShow)
row.append(QString());
return row;
};
const auto &printSettings = settings->getPrint();
QTextTableFormat tableFormat;
tableFormat.setBorder(printSettings.tableBorderWidth);
tableFormat.setBorderStyle(static_cast<QTextFrameFormat::BorderStyle>(printSettings.tableBorderStyle));
tableFormat.setColumns(columnsCount);
tableFormat.setAlignment(Qt::AlignHCenter);
tableFormat.setWidth(QTextLength(QTextLength::VariableLength, 100));
tableFormat.setBorderBrush(QBrush(printSettings.tableBorderColor));
tableFormat.setCellSpacing(printSettings.cellSpacing);
tableFormat.setCellPadding(printSettings.cellPadding);
PrintTable print(columnsCount, tableFormat);
{
auto &textFormat = print.getTableBodyTextFormat();
textFormat.setFont(printSettings.tableTextFont);
textFormat.setForeground(QBrush(printSettings.tableTextColor));
//.........这里部分代码省略.........