本文整理汇总了C++中QWebElement::replace方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebElement::replace方法的具体用法?C++ QWebElement::replace怎么用?C++ QWebElement::replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebElement
的用法示例。
在下文中一共展示了QWebElement::replace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendPublicMessage
void lmcMessageLog::appendPublicMessage(QString* lpszUserId, QString* lpszUserName, QString* lpszMessage,
QDateTime *pTime, QFont *pFont, QColor *pColor) {
QString html = QString::null;
bool localUser = (lpszUserId->compare(localId) == 0);
decodeMessage(lpszMessage);
QString fontStyle = getFontStyle(pFont, pColor, localUser);
if(lpszUserId->compare(lastId) != 0) {
outStyle = !outStyle;
html = outStyle ? themeData.outMsg : themeData.inMsg;
// get the avatar image for this user from the cache folder
QString filePath = participantAvatars.value(*lpszUserId);
// if image not found, use the default avatar image for this user
QString iconPath = QFile::exists(filePath) ? QUrl::fromLocalFile(filePath).toString() : "qrc"AVT_DEFAULT;
html.replace("%iconpath%", iconPath);
html.replace("%sender%", *lpszUserName);
html.replace("%time%", getTimeString(pTime));
html.replace("%style%", fontStyle);
html.replace("%message%", *lpszMessage);
QWebFrame* frame = page()->mainFrame();
QWebElement document = frame->documentElement();
QWebElement body = document.findFirst("body");
body.appendInside(html);
} else {
html = outStyle ? themeData.outNextMsg : themeData.inNextMsg;
html.replace("%time%", getTimeString(pTime));
html.replace("%style%", fontStyle);
html.replace("%message%", *lpszMessage);
QWebFrame* frame = page()->mainFrame();
QWebElement document = frame->documentElement();
QWebElement body = document.findFirst("body");
QWebElement last = body.lastChild();
QWebElement insert = last.findFirst("div#insert");
insert.replace(html);
}
hasData = true;
}
示例2: addMessageTop
void QtWebKitChatView::addMessageTop(boost::shared_ptr<ChatSnippet> snippet) {
// save scrollbar maximum value
if (!topMessageAdded_) {
scrollBarMaximum_ = webPage_->mainFrame()->scrollBarMaximum(Qt::Vertical);
}
topMessageAdded_ = true;
QWebElement continuationElement = firstElement_.findFirst("#insert");
bool insert = snippet->getAppendToPrevious();
bool fallback = continuationElement.isNull();
boost::shared_ptr<ChatSnippet> newSnippet = (insert && fallback) ? snippet->getContinuationFallbackSnippet() : snippet;
QWebElement newElement = snippetToDOM(newSnippet);
if (insert && !fallback) {
Q_ASSERT(!continuationElement.isNull());
continuationElement.replace(newElement);
} else {
continuationElement.removeFromDocument();
topInsertPoint_.prependOutside(newElement);
}
firstElement_ = newElement;
if (lastElement_.isNull()) {
lastElement_ = firstElement_;
}
if (fontSizeSteps_ != 0) {
double size = 1.0 + 0.2 * fontSizeSteps_;
QString sizeString(QString().setNum(size, 'g', 3) + "em");
const QWebElementCollection spans = firstElement_.findAll("span.swift_resizable");
Q_FOREACH (QWebElement span, spans) {
span.setStyleProperty("font-size", sizeString);
}