本文整理汇总了C++中QTextImageFormat::setToolTip方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextImageFormat::setToolTip方法的具体用法?C++ QTextImageFormat::setToolTip怎么用?C++ QTextImageFormat::setToolTip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextImageFormat
的用法示例。
在下文中一共展示了QTextImageFormat::setToolTip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertFrame
bool Converter::convertFrame(const QDomElement &element)
{
QDomElement child = element.firstChildElement();
QDomElement suchild = element.lastChildElement("title");
/// svg:title alt && title
while (!child.isNull())
{
if (child.tagName() == QLatin1String("image"))
{
const QString href = child.attribute("href");
const QString xname = element.attribute("name");
QString alttitle = QString("Name:%1 - Ref:%2").arg(xname).arg(href);
if (suchild.tagName() == QLatin1String("title"))
{
alttitle.append(QString(" - Title:%1").arg(suchild.text()));
}
QTextImageFormat format;
format.setToolTip(alttitle);
format.setWidth(4.0/3.0*StyleParser::convertUnit(element.attribute("width")));
format.setHeight(4.0/3.0*StyleParser::convertUnit(element.attribute("height")));
format.setName(href);
format.setBackground(Qt::white);
m_Cursor->insertImage(format);
}
child = child.nextSiblingElement();
}
return true;
}
示例2: insertImage
void TextEdit::insertImage( const QString & path ) {
QPair< QString, QSize > imgKey( this->p_->addImageResource( path ) );
QTextCursor cursor( this->textCursor() );
QTextImageFormat format;
format.setName( imgKey.first );
format.setToolTip( imgKey.first );
format.setWidth( imgKey.second.width() );
format.setHeight( imgKey.second.height() );
cursor.insertImage( format );
this->setTextCursor( cursor );
}
示例3: r
void TextEdit::Private::replaceImage( std::map< QString, QUrl > & mapping, const QFileInfo & oldP, const QFileInfo & newP ) {
QVariant r( this->host->document()->resource( QTextDocument::ImageResource, QUrl( oldP.fileName() ) ) );
this->host->document()->addResource( QTextDocument::ImageResource, QUrl( oldP.fileName() ), QVariant() );
this->host->document()->addResource( QTextDocument::ImageResource, QUrl( newP.fileName() ), r );
this->currentCursor.deletePreviousChar();
QTextImageFormat format;
format.setName( newP.fileName() );
format.setToolTip( newP.fileName() );
this->currentCursor.insertImage( format );
mapping.erase( oldP.fileName() );
mapping.insert( std::make_pair( newP.fileName(), QUrl::fromLocalFile( newP.absoluteFilePath() ) ) );
this->testCase->setImageMapping( mapping );
}
示例4: stressTestPaint
void QTextPanel::stressTestPaint()
{
/////////pageClear(); /* remove all if exist text */
QTextDocument *playdoc = new QTextDocument();
QTextCursor c(playdoc);
c.setPosition(0,QTextCursor::MoveAnchor);
int loop = -1;
c.beginEditBlock();
QStringList colorNames = QColor::colorNames();
foreach (QString name, colorNames) {
loop++;
if (loop != 0) {
c.insertBlock();
}
////////qDebug() << "### name ->" << name;
QPixmap e = createColorMaps( name );
playdoc->addResource(QTextDocument::ImageResource,QUrl(name),e);
QTextImageFormat format;
format.setName( name );
format.setHeight ( e.height() );
format.setWidth ( e.width() );
format.setToolTip(name);
c.insertImage( format );
c.insertText(QString(QChar::LineSeparator)); /* br */
////////////QTextBlockFormat bbformat = c.blockFormat();
/////////bbformat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysAfter);
////////c.setBlockFormat(bbformat);
for (int i = 0; i < 15; ++i) {
c.insertText(name+ " .");
}
c.endEditBlock();
c.atBlockEnd();
}
示例5: addContactEntry
void ContactListEdit::addContactEntry(const QString& contactText, const bts::addressbook::contact& c,
bool rawPublicKey, const QString* entryTooltip /*= nullptr*/)
{
QFont default_font;
default_font.setPointSize( default_font.pointSize() - 1 );
default_font.setBold(rawPublicKey);
QFontMetrics font_metrics(default_font);
QRect bounding = font_metrics.boundingRect(contactText);
int completion_width = font_metrics.width(contactText);
int completion_height = bounding.height();
completion_width += 20;
QImage completion_image(completion_width, completion_height + 4, QImage::Format_ARGB32);
completion_image.fill(QColor(0, 0, 0, 0) );
QPainter painter;
painter.begin(&completion_image);
painter.setFont(default_font);
painter.setRenderHint(QPainter::Antialiasing);
QBrush brush(Qt::SolidPattern);
brush.setColor( QColor( 205, 220, 241 ) );
QPen pen, textColorPen;
bool isKeyhoteeFounder = rawPublicKey == false && Contact::isKeyhoteeFounder(c);
if (isKeyhoteeFounder)
{
QLinearGradient grad(QPointF(0, 0), QPointF(0, 1));
grad.setCoordinateMode(QGradient::ObjectBoundingMode);
grad.setColorAt(0, QColor(35, 40, 3));
grad.setColorAt(0.102273, QColor(136, 106, 22));
grad.setColorAt(0.225, QColor(166, 140, 41));
grad.setColorAt(0.285, QColor(204, 181, 74));
grad.setColorAt(0.345, QColor(235, 219, 102));
grad.setColorAt(0.415, QColor(245, 236, 112));
grad.setColorAt(0.52, QColor(209, 190, 76));
grad.setColorAt(0.57, QColor(187, 156, 51));
grad.setColorAt(0.635, QColor(168, 142, 42));
grad.setColorAt(0.695, QColor(202, 174, 68));
grad.setColorAt(0.75, QColor(218, 202, 86));
grad.setColorAt(0.815, QColor(208, 187, 73));
grad.setColorAt(0.88, QColor(187, 156, 51));
grad.setColorAt(0.935, QColor(137, 108, 26));
grad.setColorAt(1, QColor(35, 40, 3));
brush = QBrush(grad);
pen.setColor( QColor( 103, 51, 1 ) );
}
else
{
if(rawPublicKey)
{
brush.setColor(QColor(Qt::darkGreen));
textColorPen.setColor(QColor(Qt::white));
}
else
{
brush.setColor( QColor( 205, 220, 241 ) );
pen.setColor( QColor( 105,110,180 ) );
}
}
painter.setBrush(brush);
painter.setPen(pen);
painter.drawRoundedRect(0, 0, completion_width - 1, completion_image.height() - 1, 8, 8,
Qt::AbsoluteSize);
painter.setPen(textColorPen);
painter.drawText(QPoint(10, completion_height - 2), contactText);
QTextDocument* doc = document();
doc->addResource(QTextDocument::ImageResource, QUrl(contactText), completion_image);
QTextImageFormat format;
format.setName(contactText);
encodePublicKey(c.public_key, &format);
if(entryTooltip != nullptr)
format.setToolTip(*entryTooltip);
QTextCursor txtCursor = textCursor();
txtCursor.insertImage(format);
setTextCursor(txtCursor);
}