本文整理汇总了C++中QTextImageFormat::property方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextImageFormat::property方法的具体用法?C++ QTextImageFormat::property怎么用?C++ QTextImageFormat::property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextImageFormat
的用法示例。
在下文中一共展示了QTextImageFormat::property方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertFromMimeData
void QTextBrowserEx::insertFromMimeData( const QMimeData *source )
{
Q_ASSERT(source);
if(m_pasteFlags == NotSupport)
return;
QByteArray bytes = source->data(KTextEditMime);
KTextCursor tc = textCursor();
if(!bytes.isEmpty() && m_pasteFlags.testFlag(Custom))
{
QDataStream ds(bytes);
QList<QByteArray> lstFrags;
ds >> lstFrags;
for(int i = 0; i < lstFrags.count(); i++)
{
const QByteArray frags = lstFrags.at(i);
QDataStream ds(frags);
QString text;
QTextCharFormat format;
ds >> text >> format;
bool bHandled = false;
/*自定义控件,则可由外部处理*/
emit insertMimiData(tc, text, format, bHandled);
if(bHandled)
continue;
/*尝试主动处理相关信息。*/
if(text.at(0) == QChar::ObjectReplacementCharacter)
{
for(int i = 0; i < text.length(); i++)
{
QTextImageFormat fmt = format.toImageFormat();
if(!fmt.isValid())
{
/*自定义控件出现比较多*/
continue;
}
QVariant vimgkey = fmt.property(KImageKey);
QString imgkey = vimgkey.toString();
tc.insertImage(imgkey, fmt);
}
}
else
{
/*文字处理*/
tc.insertText(text, format);
}
}
return;
}
示例2: decodePublicKey
void ContactListEdit::decodePublicKey(const QTextImageFormat& storage,
IMailProcessor::TRecipientPublicKey* key) const
{
assert(storage.hasProperty(QTextImageFormat::UserProperty));
QVariant v = storage.property(QTextImageFormat::UserProperty);
QByteArray pkArray = v.toByteArray();
fc::ecc::public_key_data s;
assert(pkArray.size() == s.size());
memcpy(s.begin(), pkArray.data(), s.size());
*key = IMailProcessor::TRecipientPublicKey(s);
assert(key->valid());
}
示例3: switch
void KDReports::TextDocumentData::updatePercentSize( QTextImageFormat& imageFormat, const QSizeF& size )
{
// "W50" means W=50%. "H60" means H=60%.
QString prop = imageFormat.property( ResizableImageProperty ).toString();
const qreal imageRatio = imageFormat.height() / imageFormat.width();
const qreal pageWidth = size.width();
const qreal pageHeight = size.height();
const qreal pageRatio = pageWidth ? pageHeight / pageWidth : 0;
if ( prop[0] == QLatin1Char( 'T' ) ) {
//qDebug() << "updatePercentSize fitToPage" << imageRatio << pageRatio;
if ( imageRatio < pageRatio ) {
prop = QString::fromLatin1( "W100" );
} else {
prop = QString::fromLatin1( "H100" );
}
}
const qreal percent = prop.mid( 1 ).toDouble();
switch ( prop[0].toLatin1() ) {
case 'W':
{
const qreal newWidth = pageWidth * percent / 100.0;
imageFormat.setWidth( newWidth );
imageFormat.setHeight( newWidth * imageRatio );
// ### I needed to add this -2 here for 100%-width images to fit in
if ( percent == 100.0 )
imageFormat.setWidth( imageFormat.width() - 2 );
}
break;
case 'H':
imageFormat.setHeight( pageHeight * percent / 100.0 );
// ### I needed to add -6 here for 100%-height images to fit in (with Qt-4.4)
// and it became -9 with Qt-4.5, and even QtSw doesn't know why.
// Task number 241890
if ( percent == 100.0 )
imageFormat.setHeight( imageFormat.height() - 10 );
imageFormat.setWidth( imageRatio ? imageFormat.height() / imageRatio : 0 );
//qDebug() << "updatePercentSize" << size << "->" << imageFormat.width() << "x" << imageFormat.height();
break;
default:
qWarning( "Unhandled image format property type - internal error" );
}
}