当前位置: 首页>>代码示例>>C++>>正文


C++ QTextImageFormat::merge方法代码示例

本文整理汇总了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() );
      }
    }
  }
开发者ID:adrpo,项目名称:OMNotebook,代码行数:45,代码来源:textcursorcommands.cpp

示例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;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:99,代码来源:qtextdocumentfragment.cpp


注:本文中的QTextImageFormat::merge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。