Hi
I am still playing with odt documents.
I have created a document within a QT application and am using OpenXML/ODF Translator Add-in for Office to convert it.
The document contains a table and an image.
When I open the document I see the plain text and the table, but the format I applied to the table is not visible (solid borders) and I see no image. Do you have any ide why this is?
Code for table
"Phone bill for %1\n").arg(client));
tableFormat.setBorderStyle(
m_cursor.insertTable(1, 3,tableFormat);
m_cursor.
insertText(QObject::tr("Date"));
m_cursor.
insertText(QObject::tr("Duration (sec)"));
m_cursor.
insertText(QObject::tr("Cost"));
m_cursor.insertText(QObject::tr(
"Phone bill for %1\n").arg(client));
QTextTableFormat tableFormat;
tableFormat.setBorderStyle(
QTextFrameFormat::BorderStyle_Double);
m_cursor.insertTable(1, 3,tableFormat);
m_cursor.insertText(QObject::tr("Date"));
m_cursor.movePosition(QTextCursor::NextCell);
m_cursor.insertText(QObject::tr("Duration (sec)"));
m_cursor.movePosition(QTextCursor::NextCell);
m_cursor.insertText(QObject::tr("Cost"));
To copy to clipboard, switch view to plain text mode
Code for image
const int columnSize = 10;
int width = values.count() * columnSize;
int max = 0;
foreach (int x, values)
max = qMax(max, x);
painter.fillRect(0, 0, image.width(), image.height(),
Qt::red); // background
for (int index = 0; index < values.count(); ++index) {
// Adjust scale to our 100 pixel tall image:
int height = values[index] * 100 / max;
painter.fillRect(index * columnSize,
image.height() - height, columnSize, height,
Qt::black);
}
painter.end();
cursor.insertText(subtext);
cursor.insertBlock();
cursor.insertImage(image);
const int columnSize = 10;
int width = values.count() * columnSize;
int max = 0;
foreach (int x, values)
max = qMax(max, x);
QImage image(width, 100, QImage::Format_Mono);
QPainter painter(&image);
painter.fillRect(0, 0, image.width(), image.height(),
Qt::red); // background
for (int index = 0; index < values.count(); ++index) {
// Adjust scale to our 100 pixel tall image:
int height = values[index] * 100 / max;
painter.fillRect(index * columnSize,
image.height() - height, columnSize, height,
Qt::black);
}
painter.end();
QTextCursor cursor(m_document);
cursor.movePosition(QTextCursor::End);
cursor.insertText(subtext);
cursor.insertBlock();
cursor.insertImage(image);
To copy to clipboard, switch view to plain text mode
TIA
Graham
Bookmarks