本文整理汇总了C++中QTextTableFormat::setHeaderRowCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableFormat::setHeaderRowCount方法的具体用法?C++ QTextTableFormat::setHeaderRowCount怎么用?C++ QTextTableFormat::setHeaderRowCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTableFormat
的用法示例。
在下文中一共展示了QTextTableFormat::setHeaderRowCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeTable
bool OutputQtDocument::writeTable()
{
/*
start of table
*/
m_cursor.beginEditBlock();
m_cursor.insertBlock();
m_cursor.insertBlock();
QTextFrame *topFrame = m_cursor.currentFrame();
QTextTableFormat tableFormat;
tableFormat.setCellPadding(4);
tableFormat.setHeaderRowCount(1);
/* tableFormat.setBorderStyle(
QTextFrameFormat::BorderStyle_Double); */
tableFormat.setMargin(2);
tableFormat.setWidth(QTextLength(
QTextLength::PercentageLength, 100));
QTextTable *table = m_cursor.insertTable(
m_params->height()+2, m_params->width()+5, tableFormat);
/*
headers
*/
m_cursor = table->cellAt(0, 0).firstCursorPosition();
m_cursor.insertText("i");
m_cursor = table->cellAt(0, 1).firstCursorPosition();
m_cursor.insertText(tr("basis"));
m_cursor = table->cellAt(0, 2).firstCursorPosition();
m_cursor.insertHtml("C<sub>i</sub> ");
m_cursor = table->cellAt(0, 3).firstCursorPosition();
m_cursor.insertText("B");
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(0, j+4).firstCursorPosition();
m_cursor.insertHtml(QString("P<sub>%1</sub> ").arg(j+1));
/* m_cursor.insertHtml(QString("C<sub>%1</sub> =").arg(j+1));
if(m_params->variableType(j) == SimplexMethod::VariableArtificial)
m_cursor.insertText("W");
else
m_cursor.insertText(formatDouble(m_params->rowC(j))); */
}
m_cursor = table->cellAt(0, m_params->width()+4).firstCursorPosition();
m_cursor.insertText(QChar(0x0398)); // theta
/*
matrix, columnCompareOp, columnB, columnTheta
*/
for(size_t i=0; i < m_params->height(); i++)
{
m_cursor = table->cellAt(i+1, 0).firstCursorPosition();
m_cursor.insertText(QString("%1").arg(i+1));
// basis
m_cursor = table->cellAt(i+1, 1).firstCursorPosition();
size_t basisColumn = m_params->columnBasis(i);
m_cursor.insertHtml(QString("P<sub>%1</sub> ").arg(basisColumn+1));
// basis C
m_cursor = table->cellAt(i+1, 2).firstCursorPosition();
if(m_params->variableType(basisColumn) == SimplexMethod::VariableArtificial)
m_cursor.insertText("W");
else
m_cursor.insertText(formatDouble(m_params->rowC(basisColumn)));
// B
m_cursor = table->cellAt(i+1, 3).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->columnB(i)));
// matrix
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(i+1, j+4).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->matrixA(i, j)));
}
// theta
m_cursor = table->cellAt(i+1, m_params->width()+4).firstCursorPosition();
if(m_params->columnTheta(i) > 0)
m_cursor.insertText(formatDouble(m_params->columnTheta(i)));
else
m_cursor.insertText("-");
}
/*
m+1 row
*/
m_cursor = table->cellAt(m_params->height()+1, 0).firstCursorPosition();
m_cursor.insertText("m+1");
m_cursor = table->cellAt(m_params->height()+1, 3).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->F()));
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(m_params->height()+1, j+4).firstCursorPosition();
//.........这里部分代码省略.........
示例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: render
bool KoReportODTRenderer::render(const KoReportRendererContext& context, ORODocument* document, int /*page*/)
{
QTextTableFormat tableFormat;
tableFormat.setCellPadding(5);
tableFormat.setHeaderRowCount(1);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
QTextTable *table = m_cursor.insertTable(1, 1, tableFormat);
long renderedSections = 0;
for (long s = 0; s < document->sections(); s++) {
OROSection *section = document->section(s);
section->sortPrimatives(OROSection::SortX);
if (section->type() == KRSectionData::GroupHeader || section->type() == KRSectionData::GroupFooter ||
section->type() == KRSectionData::ReportHeader || section->type() == KRSectionData::ReportFooter ||
section->type() == KRSectionData::Detail){
//Add this section to the document
//Resize the table to accomodate all the primitives in the section
if (table->columns() < section->primitives()) {
table->appendColumns(section->primitives() - table->columns());
}
if (renderedSections > 0) {
//We need to back a row, then forward a row to get at the start cell
m_cursor.movePosition(QTextCursor::PreviousRow);
m_cursor.movePosition(QTextCursor::NextRow);
} else {
//On the first row, ensure we are in the first cell after expanding the table
while (m_cursor.movePosition(QTextCursor::PreviousCell)){}
}
//Render the objects in each section
for (int i = 0; i < section->primitives(); i++) {
//Colour the cell using hte section background colour
OROPrimitive * prim = section->primitive(i);
QTextTableCell cell = table->cellAt(m_cursor);
QTextCharFormat format = cell.format();
format.setBackground(section->backgroundColor());
cell.setFormat(format);
if (prim->type() == OROTextBox::TextBox) {
OROTextBox * tb = (OROTextBox*) prim;
m_cursor.insertText(tb->text());
} else if (prim->type() == OROImage::Image) {
OROImage * im = (OROImage*) prim;
m_cursor.insertImage(im->image().scaled(im->size().width(), im->size().height(), Qt::KeepAspectRatio));
} else if (prim->type() == OROPicture::Picture) {
OROPicture * im = (OROPicture*) prim;
QImage image(im->size().toSize(), QImage::Format_RGB32);
QPainter painter(&image);
im->picture()->play(&painter);
m_cursor.insertImage(image);
} else {
kDebug() << "unhandled primitive type";
}
m_cursor.movePosition(QTextCursor::NextCell);
}
if (s < document->sections() - 1) {
table->appendRows(1);
}
renderedSections++;
}
}
QTextDocumentWriter writer(context.destinationUrl.toLocalFile());
return writer.write(m_document);
}