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


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

本文整理汇总了C++中QTextImageFormat::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextImageFormat::setProperty方法的具体用法?C++ QTextImageFormat::setProperty怎么用?C++ QTextImageFormat::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTextImageFormat的用法示例。


在下文中一共展示了QTextImageFormat::setProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: insertImage

void KTextCursor::insertImage( const QString &name, const QTextImageFormat &format )
{
	QTextImageFormat imageForamt = format;

	imageForamt.setName(name);
	if(!imageForamt.hasProperty(KImageKey))
	{
		imageForamt.setProperty(KImageKey, name);
	}

	if(moviePool()->insertMovie(name, name))
	{
		Q_D(KTextCursor);

		imageForamt.setProperty(KAnimationImage,true);
		document()->addResource(QTextDocument::ImageResource, QUrl(name), moviePool()->currentImage(name));
	}
	else
	{
		QImage image(name);
		if(!image.isNull())
		{
			document()->addResource(QTextDocument::ImageResource,QUrl(name), image);
		}
	}

	__super::insertImage(imageForamt);
}
开发者ID:kxtry,项目名称:kxfw,代码行数:28,代码来源:ktextcursor.cpp

示例2: setLatex

void TextResultItem::setLatex(Cantor::LatexResult* result)
{
    QTextCursor cursor = textCursor();
    cursor.movePosition(QTextCursor::Start);
    cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
    QString latex = result->toLatex().trimmed();
    if (latex.startsWith(QLatin1String("\\begin{eqnarray*}")) &&
        latex.endsWith(QLatin1String("\\end{eqnarray*}"))) {
        latex = latex.mid(17);
        latex = latex.left(latex.size() - 15);
    }
    if (result->isCodeShown()) {
        if (latex.isEmpty())
            cursor.removeSelectedText();
        else
            cursor.insertText(latex);
    } else {
        QTextImageFormat format;
        format = epsRenderer()->render(cursor.document(),
                                       result->data().toUrl());
        format.setProperty(EpsRenderer::CantorFormula,
                           EpsRenderer::LatexFormula);
        format.setProperty(EpsRenderer::Code, latex);
        format.setProperty(EpsRenderer::Delimiter, QLatin1String("$$"));
        if(format.isValid())
            cursor.insertText(QString(QChar::ObjectReplacementCharacter), format);
        else
            cursor.insertText(i18n("Cannot render Eps file. You may need additional packages"));
    }
}
开发者ID:KDE,项目名称:cantor,代码行数:30,代码来源:textresultitem.cpp

示例3: insertHtml

void KTextCursor::insertHtml( const QString &text, const QMap<QString, QString>& imgs )
{
	if(!imgs.isEmpty())
	{
		for(QMap<QString,QString>::const_iterator iter = imgs.begin(); iter != imgs.end(); iter++)
		{
			QString key = iter.key();
			QString file = iter.value();
			if(moviePool()->insertMovie(file, file))
			{
				//修改属性为动画。
				document()->addResource(QTextDocument::ImageResource, QUrl(file), moviePool()->currentImage(file));
			}
			else
			{
				QImage image(file);
				if(!image.isNull())
				{
					document()->addResource(QTextDocument::ImageResource, QUrl(file), image);
				}
			}
		}
	}

	int istart = position();
	insertHtml(text);
	int inow = position();

	if(!imgs.isEmpty() && inow > istart)
	{
		setPosition(istart);
		movePosition(NextCharacter, KeepAnchor, inow-istart);
		QString txt = selectedText();
		int index = txt.indexOf(QChar::ObjectReplacementCharacter, 0);
		while(index >= 0)
		{
			/*修改字体类型。*/
			setPosition(istart+index);
			movePosition(NextCharacter, KeepAnchor, 1);
			QTextCharFormat fmt = charFormat();			
			QTextImageFormat imgFmt = fmt.toImageFormat();
			QString key = imgFmt.name();
			if(imgs.contains(key))
			{
				imgFmt.setProperty(KImageKey, key);
				imgFmt.setName(imgs.value(key));
				imgFmt.setProperty(KAnimationImage, true);
				setCharFormat(imgFmt);
			}
			int idx = index+1;
			index = txt.indexOf(QChar::ObjectReplacementCharacter, idx);
		}
	}

	setPosition(inow);
}
开发者ID:kxtry,项目名称:kxfw,代码行数:56,代码来源:ktextcursor.cpp

示例4: render

QTextImageFormat EpsRenderer::render(QTextDocument *document,
                                     const Cantor::LatexRenderer* latex)
{
    QTextImageFormat format = render(document, QUrl::fromLocalFile(latex->imagePath()));

    if (!format.name().isEmpty()) {
        format.setProperty(CantorFormula, latex->method());
        format.setProperty(ImagePath, latex->imagePath());
        format.setProperty(Code, latex->latexCode());
    }

    return format;
}
开发者ID:KDE,项目名称:cantor,代码行数:13,代码来源:epsrenderer.cpp


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