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


C++ QMimeData::html方法代码示例

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


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

示例1: getHtml

/**
 * Returns HTML markup for selected text. If no text is selected, returns
 * HTML markup for all text.
 */
QString PsiTextView::getHtml() const
{
	PsiTextView *ptv = (PsiTextView *)this;
	QTextCursor cursor = ptv->textCursor();
	int position = ptv->verticalScrollBar()->value();
	
	bool unselectAll = false;
	if (!hasSelectedText()) {
		ptv->selectAll();
		unselectAll = true;
	}
	
	QMimeData *mime = createMimeDataFromSelection();
	QString result = mime->html();
	delete mime;
	
	// we need to restore original position if selectAll() 
	// was called, because setTextCursor() (which is necessary
	// to clear selection) will move vertical scroll bar
	if (unselectAll) {
		cursor.clearSelection();
		ptv->setTextCursor(cursor);
		ptv->verticalScrollBar()->setValue(position);
	}
	
	return result;
}
开发者ID:sapo,项目名称:sapo-messenger-for-mac,代码行数:31,代码来源:psitextview.cpp

示例2: setHtml

void tst_QMimeData::setHtml() const
{
    QMimeData mimeData;

    // initial state
    QVERIFY(mimeData.hasHtml() == false);

    // add html, verify
    mimeData.setHtml("ninjas");
    QVERIFY(mimeData.hasHtml());
    QCOMPARE(mimeData.html(), QLatin1String("ninjas"));

    // reset html
    mimeData.setHtml("pirates");
    QVERIFY(mimeData.hasHtml());
    QCOMPARE(mimeData.html(), QLatin1String("pirates"));
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:17,代码来源:tst_qmimedata.cpp

示例3: data

void tst_QMimeData::data() const
{
    QMimeData mimeData;

    // set text, verify
    mimeData.setData("text/plain", "pirates");
    QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates"));
    QVERIFY(mimeData.data("text/html").length() == 0);

    // html time
    mimeData.setData("text/html", "ninjas");
    QCOMPARE(mimeData.data("text/html"), QByteArray("ninjas"));
    QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates")); // make sure text not damaged
    QCOMPARE(mimeData.data("text/html"), mimeData.html().toLatin1());
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:15,代码来源:tst_qmimedata.cpp

示例4:

QDebug operator<<(QDebug d, const QMimeData &m)
{
    QDebug nospace = d.nospace();
    const QStringList formats = m.formats();
    nospace << "QMimeData: " << formats.join(QStringLiteral(", ")) << '\n'
            << "  Text=" << m.hasText() << " HTML=" << m.hasHtml()
            << " Color=" << m.hasColor() << " Image=" << m.hasImage()
            << " URLs=" << m.hasUrls() << '\n';
    if (m.hasText())
        nospace << "  Text: '" << m.text() << "'\n";
    if (m.hasHtml())
        nospace << "  HTML: '" << m.html() << "'\n";
    if (m.hasColor())
        nospace << "  Color: " << qvariant_cast<QColor>(m.colorData()) << '\n';
    if (m.hasImage())
        nospace << "  Image: " << qvariant_cast<QImage>(m.imageData()).size() << '\n';
    if (m.hasUrls())
        nospace << "  URLs: " << m.urls() << '\n';
    return d;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:20,代码来源:qwindowsclipboard.cpp

示例5: getTextHelper

QString PsiTextView::getTextHelper(bool html) const
{
	PsiTextView *ptv = (PsiTextView *)this;
	QTextCursor cursor = ptv->textCursor();
	int position = ptv->verticalScrollBar()->value();

	bool unselectAll = false;
	if (!textCursor().hasSelection()) {
#if QT_VERSION == 0x040701
		// workaround for crash when deleting last character with backspace (qt-4.7.1)
		// http://bugreports.qt.nokia.com/browse/QTBUG-15857
		QTextCursor tempCursor = QTextCursor(ptv->document());
		tempCursor.movePosition(QTextCursor::Start);
		ptv->setTextCursor(tempCursor);
#endif
		ptv->selectAll();
		unselectAll = true;
	}

	QMimeData *mime = createMimeDataFromSelection();
	QString result;
	if (html)
		result = mime->html();
	else
		result = mime->text();
	delete mime;

	// we need to restore original position if selectAll()
	// was called, because setTextCursor() (which is necessary
	// to clear selection) will move vertical scroll bar
	if (unselectAll) {
		cursor.clearSelection();
		ptv->setTextCursor(cursor);
		ptv->verticalScrollBar()->setValue(position);
	}

	return result;
}
开发者ID:diger,项目名称:psi-plus-snapshots,代码行数:38,代码来源:psitextview.cpp


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