本文整理汇总了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);
}
示例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"));
}
}
示例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);
}
示例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;
}