本文整理汇总了C++中QTextTable::appendRows方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTable::appendRows方法的具体用法?C++ QTextTable::appendRows怎么用?C++ QTextTable::appendRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTable
的用法示例。
在下文中一共展示了QTextTable::appendRows方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printODT
//.........这里部分代码省略.........
topLeftFormat.setProperty( QTextFormatUserDefined::TableCellBorderTopWidth, QVariant(borderWidth) );
QTextTableCellFormat topRightFormat;
topRightFormat.setProperty( QTextFormatUserDefined::TableCellBorderRightStyle, QVariant(QTextFrameFormat::BorderStyle_Solid) );
topRightFormat.setProperty( QTextFormatUserDefined::TableCellBorderRightWidth, QVariant(borderWidth) );
topRightFormat.setProperty( QTextFormatUserDefined::TableCellBorderTopStyle, QVariant(QTextFrameFormat::BorderStyle_Solid) );
topRightFormat.setProperty( QTextFormatUserDefined::TableCellBorderTopWidth, QVariant(borderWidth) );
QTextTableCellFormat bottomFormat;
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderLeftStyle, QVariant(QTextFrameFormat::BorderStyle_Solid) );
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderLeftWidth, QVariant(borderWidth) );
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderRightStyle, QVariant(QTextFrameFormat::BorderStyle_Solid) );
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderRightWidth, QVariant(borderWidth) );
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderBottomStyle, QVariant(QTextFrameFormat::BorderStyle_Solid) );
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderBottomWidth, QVariant(borderWidth) );
// tabella con informazioni generali sul prezzo
// descrizione, codice, etc
QTextTableFormat tableFormat;
tableFormat.setCellPadding(5);
tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid);
tableFormat.setWidth( QTextLength( QTextLength::FixedLength, tableWidth ) );
QVector<QTextLength> colWidths;
colWidths << QTextLength( QTextLength::FixedLength, 25 )
<< QTextLength( QTextLength::FixedLength, pageWidth-2.0*margin - 25 );
tableFormat.setColumnWidthConstraints( colWidths );
QTextTable * table = cursor.insertTable(1, colWidths.size(), tableFormat);
table->cellAt( cursor ).setFormat( topLeftFormat );
cursor.insertText( priceItemList.at(i)->codeFull() );
cursor.movePosition(QTextCursor::NextCell);
table->cellAt( cursor ).setFormat( topRightFormat );
cursor.insertText( priceItemList.at(i)->shortDescriptionFull() );
table->appendRows(1);
table->mergeCells( 1, 0, 1, 2 );
cursor.movePosition(QTextCursor::PreviousRow );
cursor.movePosition(QTextCursor::NextCell );
table->cellAt( cursor ).setFormat( bottomFormat );
cursor.insertText( priceItemList.at(i)->longDescriptionFull() );
cursor.movePosition( QTextCursor::End );
// tabella con l'analisi prezzi vera e propria
tableFormat.setCellPadding(5);
tableFormat.setHeaderRowCount(2);
tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid);
tableFormat.setWidth( QTextLength( QTextLength::FixedLength, tableWidth ) );
colWidths.clear();
if( paperOrientation == Qt::Horizontal ){
if( fieldsToPrint.size() > 0 ){
colWidths << QTextLength( QTextLength::FixedLength, 10.0 )
<< QTextLength( QTextLength::FixedLength, 30.0 )
<< QTextLength( QTextLength::FixedLength, 70.0 )
<< QTextLength( QTextLength::FixedLength, 20.0 );
double usedWidth = 10.0 + 30.0 + 70.0 + 20.0;
double colEqualWidth = (tableWidth - usedWidth ) / (1 + 2*fieldsToPrint.size() );
for( int i=0; i < (1 + 2*fieldsToPrint.size() ); ++i ){
colWidths << QTextLength( QTextLength::FixedLength, colEqualWidth );
}
} else { // fieldsToPrint.size() == 0
if( fieldsToPrint.size() > 1 ){
double descWidth = tableWidth - (10.0 + 30.0 + 20.0 + 30.0);
colWidths << QTextLength( QTextLength::FixedLength, 10.0 )
<< QTextLength( QTextLength::FixedLength, 30.0 )
<< QTextLength( QTextLength::FixedLength, descWidth )
<< QTextLength( QTextLength::FixedLength, 20.0 )
<< QTextLength( QTextLength::FixedLength, 30.0 );
示例2: 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 accommodate 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 {
kWarning() << "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);
}
示例3: uri
/** "Help message" or "About" dialog box */
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
QDialog(parent),
ui(new Ui::HelpMessageDialog)
{
ui->setupUi(this);
GUIUtil::restoreWindowGeometry("nHelpMessageDialogWindow", this->size(), this);
QString version = tr("Unobtanium Core") + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion());
/* On x86 add a bit specifier to the version so that users can distinguish between
* 32 and 64 bit builds. On other architectures, 32/64 bit may be more ambigious.
*/
#if defined(__x86_64__)
version += " " + tr("(%1-bit)").arg(64);
#elif defined(__i386__ )
version += " " + tr("(%1-bit)").arg(32);
#endif
if (about)
{
setWindowTitle(tr("About Unobtanium Core"));
/// HTML-format the license message from the core
QString licenseInfo = QString::fromStdString(LicenseInfo());
QString licenseInfoHTML = licenseInfo;
// Make URLs clickable
QRegExp uri("<(.*)>", Qt::CaseSensitive, QRegExp::RegExp2);
uri.setMinimal(true); // use non-greedy matching
licenseInfoHTML.replace(uri, "<a href=\"\\1\">\\1</a>");
// Replace newlines with HTML breaks
licenseInfoHTML.replace("\n\n", "<br><br>");
ui->aboutMessage->setTextFormat(Qt::RichText);
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
text = version + "\n" + licenseInfo;
ui->aboutMessage->setText(version + "<br><br>" + licenseInfoHTML);
ui->aboutMessage->setWordWrap(true);
ui->helpMessage->setVisible(false);
} else {
setWindowTitle(tr("Command-line options"));
QTextCursor cursor(ui->helpMessage->document());
cursor.insertText(version);
cursor.insertBlock();
cursor.insertText(tr("Usage:") + '\n' +
" bitcoin-qt [" + tr("command-line options") + "]\n");
cursor.insertBlock();
QTextTableFormat tf;
tf.setBorderStyle(QTextFrameFormat::BorderStyle_None);
tf.setCellPadding(2);
QVector<QTextLength> widths;
widths << QTextLength(QTextLength::PercentageLength, 35);
widths << QTextLength(QTextLength::PercentageLength, 65);
tf.setColumnWidthConstraints(widths);
QTextTable *table = cursor.insertTable(2, 2, tf);
QString coreOptions = QString::fromStdString(HelpMessage(HMM_BITCOIN_QT));
bool first = true;
QTextCharFormat bold;
bold.setFontWeight(QFont::Bold);
// note that coreOptions is not translated.
foreach (const QString &line, coreOptions.split('\n')) {
if (!first) {
table->appendRows(1);
cursor.movePosition(QTextCursor::NextRow);
}
first = false;
if (line.startsWith(" ")) {
int index = line.indexOf(' ', 3);
if (index > 0) {
cursor.insertText(line.left(index).trimmed());
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(line.mid(index).trimmed());
continue;
}
}
cursor.movePosition(QTextCursor::NextCell, QTextCursor::KeepAnchor);
table->mergeCells(cursor);
cursor.insertText(line.trimmed(), bold);
}
table->appendRows(6);
cursor.movePosition(QTextCursor::NextRow);
cursor.insertText(tr("UI options") + ":", bold);
cursor.movePosition(QTextCursor::NextRow);
if (GetBoolArg("-help-debug", false)) {
cursor.insertText("-allowselfsignedrootcertificates");
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(tr("Allow self signed root certificates (default: 0)"));
cursor.movePosition(QTextCursor::NextCell);
}
cursor.insertText("-choosedatadir");
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(tr("Choose data directory on startup (default: 0)"));
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText("-lang=<lang>");
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(tr("Set language, for example \"de_DE\" (default: system locale)"));
cursor.movePosition(QTextCursor::NextCell);
//.........这里部分代码省略.........
示例4: writeTable
//.........这里部分代码省略.........
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();
m_cursor.insertText(formatDouble(m_params->rowD(j)));
}
/*
m+2 row (for artificial variables)
*/
if(m_params->artificialFlag())
{
table->appendRows(1);
m_cursor = table->cellAt(m_params->height()+2, 0).firstCursorPosition();
m_cursor.insertText("m+2");
m_cursor = table->cellAt(m_params->height()+2, 3).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->WF()));
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(m_params->height()+2, j+4).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->rowWD(j)));
}
}
/*
end of table
*/
m_cursor.endEditBlock();
m_cursor.setPosition(topFrame->lastPosition());
return true;
}