本文整理汇总了C++中QTextImageFormat::merge方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextImageFormat::merge方法的具体用法?C++ QTextImageFormat::merge怎么用?C++ QTextImageFormat::merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextImageFormat
的用法示例。
在下文中一共展示了QTextImageFormat::merge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
/*!
* \class TextCursorInsertImage
* \author Anders Fernström
* \date 2005-11-18
*
* \brief Command for inserting an image
*/
void TextCursorInsertImage::execute()
{
QTextCursor cursor( document()->getCursor()->currentCell()->textCursor() );
if( !cursor.isNull() )
{
QImage* image = new QImage( filepath_ );
if( !image->isNull() )
{
QString imagename = document()->addImage( image );
QTextCursor cursor( document()->getCursor()->currentCell()->textCursor() );
if( !cursor.isNull() )
{
QTextEdit *editor = document()->getCursor()->currentCell()->textEdit();
if( editor )
{
// save text settings and set them after image have been inserted
QTextCharFormat format = cursor.charFormat();
if( editor->toPlainText().isEmpty() )
format = *document()->getCursor()->currentCell()->style()->textCharFormat();
QTextImageFormat imageformat;
imageformat.merge( format );
imageformat.setHeight( height_ );
imageformat.setWidth( width_ );
imageformat.setName( imagename );
cursor.insertImage( imageformat );
}
}
}
else
{
string str = string("Could not open image: ") + filepath_.toStdString().c_str();
throw runtime_error( str.c_str() );
}
}
}
示例2: processSpecialNodes
QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes()
{
switch (currentNode->id) {
case Html_body:
if (currentNode->charFormat.background().style() != Qt::NoBrush) {
QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
fmt.setBackground(currentNode->charFormat.background());
doc->rootFrame()->setFrameFormat(fmt);
const_cast<QTextHtmlParserNode *>(currentNode)->charFormat.clearProperty(QTextFormat::BackgroundBrush);
}
break;
case Html_ol:
case Html_ul: {
QTextListFormat::Style style = currentNode->listStyle;
if (currentNode->id == Html_ul && !currentNode->hasOwnListStyle && currentNode->parent) {
const QTextHtmlParserNode *n = &at(currentNode->parent);
while (n) {
if (n->id == Html_ul) {
style = nextListStyle(currentNode->listStyle);
}
if (n->parent)
n = &at(n->parent);
else
n = 0;
}
}
QTextListFormat listFmt;
listFmt.setStyle(style);
++indent;
if (currentNode->hasCssListIndent)
listFmt.setIndent(currentNode->cssListIndent);
else
listFmt.setIndent(indent);
List l;
l.format = listFmt;
l.listNode = currentNodeIdx;
lists.append(l);
compressNextWhitespace = true;
// broken html: <ul>Text here<li>Foo
const QString simpl = currentNode->text.simplified();
if (simpl.isEmpty() || simpl.at(0).isSpace())
return ContinueWithNextNode;
break;
}
case Html_table: {
Table t = scanTable(currentNodeIdx);
tables.append(t);
hasBlock = false;
return ContinueWithNextNode;
}
case Html_tr:
return ContinueWithNextNode;
case Html_img: {
QTextImageFormat fmt;
fmt.setName(currentNode->imageName);
fmt.merge(currentNode->charFormat);
if (currentNode->imageWidth >= 0)
fmt.setWidth(currentNode->imageWidth);
if (currentNode->imageHeight >= 0)
fmt.setHeight(currentNode->imageHeight);
cursor.insertImage(fmt, QTextFrameFormat::Position(currentNode->cssFloat));
cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
cursor.mergeCharFormat(currentNode->charFormat);
cursor.movePosition(QTextCursor::Right);
hasBlock = false;
return ContinueWithNextNode;
}
case Html_hr: {
QTextBlockFormat blockFormat = currentNode->blockFormat;
blockFormat.setTopMargin(topMargin(currentNodeIdx));
blockFormat.setBottomMargin(bottomMargin(currentNodeIdx));
blockFormat.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, currentNode->width);
if (hasBlock && importMode == ImportToDocument)
cursor.mergeBlockFormat(blockFormat);
else
appendBlock(blockFormat);
hasBlock = false;
return ContinueWithNextNode;
}
default: break;
}
return ContinueWithCurrentNode;
}