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


C++ QTextEdit::setHtml方法代码示例

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


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

示例1: emitChatData

/** Get a message node element, extrapolate its type (public msg, private msg, channelEnter, etc.) and emit
    the specific signal */
void AJAXChat::emitChatData(const QDomElement &message)
{
    QString messageText = message.firstChildElement("text").text();
    // decode html entities from the message text and simplify it
    QTextEdit t;
    t.setHtml(messageText);
    messageText = t.toPlainText().simplified();

    if (messageText.startsWith("/")) {
        QStringList messageParts = messageText.split(" ");
        if (messageText.startsWith("/privmsg")) {
            const int userID = message.attribute("userID").toInt();
            emit newPrivateMessage(messageParts.at(1), getUser(userID).text());
        } else if (messageText.startsWith("/login")) {
            emit userLoggedIn(messageParts.at(1));
        } else if (messageText.startsWith("/logout")) {
            emit userLoggedOut(messageParts.at(1));
            qDebug("Logged out: " + getUser(messageParts.at(1)).text().toUtf8());
        } else if (messageText.startsWith("/channelEnter")) {
            emit userJoinChannel(messageParts.at(1));
        } else if (messageText.startsWith("/channelLeave")) {
            emit userLeaveChannel(messageParts.at(1));
        } else if (messageText.startsWith("/kick")) {
            emit userKicked(messageParts.at(1));
        } else if (messageText.startsWith("/nick")) {
            emit userChangeNick(messageParts.at(1), messageParts.at(2));
        }
    } else {
        const int userID = message.attribute("userID").toInt();
        emit newPublicMessage(messageText, getUser(userID).text());
    }
}
开发者ID:Maluen,项目名称:botanna,代码行数:34,代码来源:AJAXChat.cpp

示例2: addIncomingChatMsg

/**
 * We get a new Message from a chat participant
 * 
 * - Ignore Messages from muted chat participants
 */
void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
{
	QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
	QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
	QString message = QString::fromStdWString(info.msg);
	QString name = QString::fromUtf8(info.peer_nickname.c_str());
	QString rsid = QString::fromUtf8(info.rsid.c_str());

	std::cerr << "message from rsid " << info.rsid.c_str() << std::endl;
	
	if(!isParticipantMuted(name)) {
	  ui.chatWidget->addChatMsg(true, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
		emit messageReceived(id()) ;
	}
	
	// This is a trick to translate HTML into text.
	QTextEdit editor;
	editor.setHtml(message);
	QString notifyMsg = name + ": " + editor.toPlainText();

	if(notifyMsg.length() > 30)
		MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg.left(30) + QString("..."));
	else
		MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg);

	// also update peer list.

	time_t now = time(NULL);

	if (now > lastUpdateListTime) {
		lastUpdateListTime = now;
		updateParticipantsList();
	}
}
开发者ID:boukeversteegh,项目名称:retroshare,代码行数:39,代码来源:ChatLobbyDialog.cpp

示例3: QDialog

AboutBox::AboutBox(QWidget* parent) :
    QDialog(parent)
{
    resize( 500,300);
    QTextEdit* content = new QTextEdit();
    content->setReadOnly(true);
    QString txt = "<h1>Evilpixie</h1>"
        "version 0.2<br/><br/>"
        "By Ben Campbell ([email protected])<br/><br/>"
        "Licensed under GPLv3<br/>"
        "Homepage: <a href=\"http://evilpixie.scumways.com\">http://evilpixie.scumways.com</a><br/>"
        "Source: <a href=\"http://github.com/bcampbell/evilpixie\">http://github.com/bcampbell/evilpixie</a>";

    content->setHtml(txt);

    QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(hide()));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(content);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

    setWindowTitle(tr("About EvilPixie"));


}
开发者ID:bcampbell,项目名称:evilpixie,代码行数:27,代码来源:miscwindows.cpp

示例4: slotActivHelp

// ----------------------------------------------------------------------
//->setWindowFlags(Qt::Window | Qt::WindowTitleHint);
//->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint);
// ----------------------------------------------------------------------
void WxMain::slotActivHelp(){
//    QString str = ((QPushButton*)sender())->text();
//    if (str == tr("Справка")){
        QTextEdit *txt = new QTextEdit;
        txt->setReadOnly(true);
	txt->setHtml( tr("<HTML>"
                "<BODY>"
                "<H2><CENTER> Справка </CENTER></H2>"
                "<P ALIGN=\"left\">"
                    "<BR>"
                    "<BR>"
                    "<BR>"
        	"</P>"
                "<H3><CENTER> Версия 1.2 </CENTER></H3>"
                "<H4><CENTER> Октябрьь 2013 </CENTER></H4>"
                "<H4><CENTER> Широков О.Ю. </CENTER></H4>"
                "<BR>"
                "</BODY>"
                "</HTML>"
               ));
        txt->resize(250, 200);
        txt->show();
//                "<BODY BGCOLOR=MAGENTA>"
//                "<FONT COLOR=BLUE>"
//                "</FONT>"
//    }
//    qDebug() << tr("Справка");  
return;
}// End slot
开发者ID:MiZaRUs,项目名称:SyMonTSTO,代码行数:33,代码来源:WxMain.cpp

示例5: file

HelpWindow::HelpWindow()
{
    resize( 600,500);
    QTextEdit* content = new QTextEdit();
    content->setReadOnly(true);
    {
        QFile file( JoinPath(g_App->DataPath(), "help.html").c_str() );
        if(file.open(QIODevice::ReadOnly | QIODevice::Text))
        {
            QString help_txt;
            help_txt = file.readAll();
            content->setHtml(help_txt);
        }
    }

    QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(hide()));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(content);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

    setWindowTitle(tr("Help"));
}
开发者ID:bcampbell,项目名称:evilpixie,代码行数:25,代码来源:miscwindows.cpp

示例6: editTextClicked

void EditStyle::editTextClicked(int id)
      {
      QTextEdit* e = 0;
      switch (id) {
            case  0:  e = evenHeaderL; break;
            case  1:  e = evenHeaderC; break;
            case  2:  e = evenHeaderR; break;
            case  3:  e = oddHeaderL;  break;
            case  4:  e = oddHeaderC;  break;
            case  5:  e = oddHeaderR;  break;

            case  6:  e = evenFooterL; break;
            case  7:  e = evenFooterC; break;
            case  8:  e = evenFooterR; break;
            case  9:  e = oddFooterL;  break;
            case 10:  e = oddFooterC;  break;
            case 11:  e = oddFooterR;  break;
            }
      if (e == 0)
            return;
      bool styled = id < 6 ? headerStyled->isChecked() : footerStyled->isChecked();

      if (styled)
            e->setPlainText(editPlainText(e->toPlainText(), tr("Edit Plain Text")));
      else
            e->setHtml(editHtml(e->toHtml(), tr("Edit HTML Text")));
      }
开发者ID:CFrei,项目名称:MuseScore,代码行数:27,代码来源:editstyle.cpp

示例7: qDebug

InfoPanel::InfoPanel(QWidget *parent) :QWidget(parent)
{
    #ifdef K_DEBUG
        #ifdef Q_OS_WIN
            qDebug() << "[InfoPanel()]";
        #else
            TINIT;
        #endif
    #endif

    QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);

    QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom);
    QLabel *label = new QLabel(tr("Tips"));
    label->setAlignment(Qt::AlignHCenter); 
    layout->addWidget(label);

    mainLayout->addLayout(layout);

    QTextEdit *textArea = new QTextEdit; 
    textArea->setFixedHeight(250);
    textArea->setHtml("<p><b>" + tr("X Key or Right Mouse Button") + ":</b> " + tr("Close line") + "</p>"); 
    mainLayout->addWidget(textArea);
   
    mainLayout->addStretch(2);
}
开发者ID:bedna-KU,项目名称:tupi,代码行数:26,代码来源:infopanel.cpp

示例8: on_listWidgetFormats_currentItemChanged

void ClipboardDialog::on_listWidgetFormats_currentItemChanged(
        QListWidgetItem *current, QListWidgetItem *)
{
    ui->actionRemove_Format->setEnabled(current != NULL);

    QTextEdit *edit = ui->textEditContent;
    QString mime = current ? current->text() : QString();

    edit->clear();
    const QByteArray bytes = m_data.value(mime).toByteArray();
    if ( mime.startsWith(QString("image")) ) {
        edit->document()->addResource( QTextDocument::ImageResource,
                                       QUrl("data://1"), bytes );
        edit->setHtml( QString("<img src=\"data://1\" />") );
    } else {
        QTextCodec *codec = QTextCodec::codecForName("utf-8");
        if (mime == QLatin1String("text/html"))
            codec = QTextCodec::codecForHtml(bytes, codec);
        else
            codec = QTextCodec::codecForUtfText(bytes, codec);
        edit->setPlainText( codec ? codec->toUnicode(bytes) : QString() );
    }

    ui->labelProperties->setText(
        tr("<strong> mime:</strong> %1 <strong>size:</strong> %2 bytes")
            .arg(escapeHtml(mime))
            .arg(QString::number(bytes.size())));
}
开发者ID:fade2gray,项目名称:CopyQ,代码行数:28,代码来源:clipboarddialog.cpp

示例9: addData

void dataViewer::addData(QString data) {
	QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(data));
	QTextEdit* sb =new QTextEdit();
	sb->setHtml("<h1>Hello <b>World!</b></h1>");
	sb->setAutoFillBackground(true);
    ui.dataTree->setItemWidget(item, 2, sb);
    currentItem->addChild(item);  
}
开发者ID:erikor,项目名称:Imagine,代码行数:8,代码来源:dataviewer.cpp

示例10: qDebug

ZoomConfigurator::ZoomConfigurator(QWidget *parent) :QWidget(parent)
{
    #ifdef K_DEBUG
        #ifdef Q_OS_WIN32
            qDebug() << "[ZoomConfigurator()]";
        #else
            TINIT;
        #endif
    #endif

    QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
    QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom);

    scale = new QLabel(tr("Scale Factor"));
    scale->setFont(QFont("Arial", 8, QFont::Normal, false));
    scale->setAlignment(Qt::AlignHCenter);
    layout->addWidget(scale);

    factor = new QDoubleSpinBox();

    factor->setDecimals(1);
    factor->setSingleStep(0.1);
    factor->setMinimum(0.1);
    factor->setMaximum(0.9);
    layout->addWidget(factor);

    QLabel *label = new QLabel(tr("Tips"));
    label->setAlignment(Qt::AlignHCenter);
    label->setFont(QFont("Arial", 8, QFont::Normal, false));

    QTextEdit *textArea = new QTextEdit; 

    textArea->setFont(QFont("Arial", 8, QFont::Normal, false));
    textArea->setHtml("<p><b>" + tr("Zoom Square mode") + ":</b> " + tr("Press Ctrl key + Mouse left button") + "</p>"); 

    QString text = textArea->document()->toPlainText();
    int height = (text.length()*270)/207;

    textArea->setFixedHeight(height);

    mainLayout->addLayout(layout);
    mainLayout->addWidget(label);
    mainLayout->addWidget(textArea);
    mainLayout->addStretch(2);

    TCONFIG->beginGroup("ZoomTool");
    double value = TCONFIG->value("zoomFactor", -1).toDouble();

    if (value > 0) 
        factor->setValue(value);
    else 
        factor->setValue(0.5);
}
开发者ID:KDE,项目名称:tupi,代码行数:53,代码来源:zoomconfigurator.cpp

示例11: file

EulaDialog::EulaDialog(QWidget* parent) : QWizard(parent) {
  setWindowTitle(trEulaTitle);
  setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

  //// First page
  QWizardPage* firstPage = new QWizardPage;

  QRadioButton* agreeButton = new QRadioButton(trIAgree);
  VERIFY(connect(agreeButton, &QRadioButton::clicked, this, &EulaDialog::agreeButtonClicked));

  QRadioButton* notAgreeButton = new QRadioButton(trIDontAgree);
  notAgreeButton->setChecked(true);
  VERIFY(connect(notAgreeButton, &QRadioButton::clicked, this, &EulaDialog::notAgreeButtonClicked));

  QHBoxLayout* radioButtonsLay = new QHBoxLayout;
  radioButtonsLay->setAlignment(Qt::AlignHCenter);
  radioButtonsLay->setSpacing(30);
  radioButtonsLay->addWidget(agreeButton);
  radioButtonsLay->addWidget(notAgreeButton);

  QTextEdit* textBrowser = new QTextEdit;
  QFile file(":" PROJECT_NAME_LOWERCASE "/LICENSE");
  if (file.open(QFile::ReadOnly | QFile::Text)) {
    textBrowser->setHtml(file.readAll());
  }

  QVBoxLayout* mainLayout1 = new QVBoxLayout;
  mainLayout1->addWidget(new QLabel("<h3>" + trEndUserAgr + "</h3>"));
  mainLayout1->addWidget(textBrowser);
  mainLayout1->addLayout(radioButtonsLay, Qt::AlignCenter);
  firstPage->setLayout(mainLayout1);

  addPage(firstPage);

  //// Buttons
  setButtonText(QWizard::CustomButton1, trBack);
  setButtonText(QWizard::CustomButton2, trNext);
  setButtonText(QWizard::CustomButton3, trFinish);

  VERIFY(connect(button(QWizard::CustomButton1), &QAbstractButton::clicked, this, &EulaDialog::backButtonClicked));
  VERIFY(connect(button(QWizard::CustomButton2), &QAbstractButton::clicked, this, &EulaDialog::nextButtonClicked));
  VERIFY(connect(button(QWizard::CustomButton3), &QAbstractButton::clicked, this, &EulaDialog::finishButtonClicked));

  setButtonLayout(QList<WizardButton>{QWizard::Stretch, QWizard::CustomButton1, QWizard::CustomButton2,
                                      QWizard::CancelButton, QWizard::CustomButton3});

  button(QWizard::CustomButton1)->setHidden(true);
  button(QWizard::CustomButton2)->setHidden(true);
  button(QWizard::CustomButton3)->setDisabled(true);
  setWizardStyle(QWizard::ModernStyle);
}
开发者ID:mdvx,项目名称:fastonosql,代码行数:51,代码来源:eula_dialog.cpp

示例12: main

int main(int argc, char *argv[])
{
    QWidget *parent = 0;
    QString aStringContainingHTMLtext("<h1>Scribe Overview</h1>");

    QApplication app(argc, argv);

//! [1]
    QTextEdit *editor = new QTextEdit(parent);
    editor->setHtml(aStringContainingHTMLtext);
    editor->show();
//! [1]

    return app.exec();
}
开发者ID:Kwangsub,项目名称:qt-openwebos,代码行数:15,代码来源:main.cpp

示例13: file

LicensePage::LicensePage(QWidget *parent)
    : QWizardPage(parent)
{
    setTitle(tr("License"));

    QVBoxLayout *layout = new QVBoxLayout;
    setLayout(layout);

    QTextEdit *licenseView = new QTextEdit(this);
    layout->addWidget(licenseView);
    licenseView->setReadOnly(true);

    QFile file(":/html/LICENSE.html");
    file.open(QFile::ReadOnly);
    licenseView->setHtml(file.readAll());
    file.close();
}
开发者ID:Negusbuk,项目名称:MatDB,代码行数:17,代码来源:matdbaboutdialog.cpp

示例14: addChatMsg

/**
 * We get a new Message from a chat participant
 *
 * - Ignore Messages from muted chat participants
 */
void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
{
    QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime);
    QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime);
    QString message = QString::fromUtf8(msg.msg.c_str());
    RsGxsId gxs_id = msg.lobby_peer_gxs_id ;

    if(!isParticipantMuted(gxs_id))
    {
        // We could change addChatMsg to display the peers icon, passing a ChatId

        RsIdentityDetails details ;

        QString name ;
        if(rsIdentity->getIdDetails(gxs_id,details))
            name = QString::fromUtf8(details.mNickname.c_str()) ;
        else
            name = QString::fromUtf8(msg.peer_alternate_nickname.c_str()) + " (" + QString::fromStdString(gxs_id.toStdString()) + ")" ;

        ui.chatWidget->addChatMsg(msg.incoming, name, gxs_id, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL);
        emit messageReceived(msg.incoming, id(), sendTime, name, message) ;
        SoundManager::play(SOUND_NEW_LOBBY_MESSAGE);

        // This is a trick to translate HTML into text.
        QTextEdit editor;
        editor.setHtml(message);
        QString notifyMsg = name + ": " + editor.toPlainText();

        if(notifyMsg.length() > 30)
            MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg.left(30) + QString("..."));
        else
            MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg);
    }

    // also update peer list.

    time_t now = time(NULL);

    QList<QTreeWidgetItem*>  qlFoundParticipants=ui.participantsList->findItems(QString::fromStdString(gxs_id.toStdString()),Qt::MatchExactly,COLUMN_ID);
    if (qlFoundParticipants.count()!=0) qlFoundParticipants.at(0)->setText(COLUMN_ACTIVITY,QString::number(now));

    if (now > lastUpdateListTime) {
        lastUpdateListTime = now;
        updateParticipantsList();
    }
}
开发者ID:dtschmitz,项目名称:RetroShare,代码行数:51,代码来源:ChatLobbyDialog.cpp

示例15: on_btn_kopiraj_clicked

void wid_stranke::on_btn_kopiraj_clicked() {

	QClipboard *odlozisce = QApplication::clipboard();

	QModelIndexList selectedList = ui->tbl_stranke->selectionModel()->selectedRows();

	QString html_besedilo = "<table>";
	html_besedilo += "<tr>";
	html_besedilo += "<th>ID</th>";
	html_besedilo += "<th>Ime/Naziv</th>";
	html_besedilo += "<th>Priimek/Polni naziv</th>";
	html_besedilo += "<th>Telefon</th>";
	html_besedilo += "<th>GSM</th>";
	html_besedilo += "<th>Elektronski naslov</th>";
	html_besedilo += "<th>Izobrazevalna ustanova</th>";
	html_besedilo += "<th>Tip stranke</th>";
	html_besedilo += "</tr>";

	for( int i = 0; i < selectedList.count(); i++) {
		html_besedilo += "<tr>";
		for ( int a = 0; a < 8; a++ ) {
			html_besedilo += "<td>";
			html_besedilo += ui->tbl_stranke->item(selectedList.at(i).row(), a)->text();
			html_besedilo += "</td>";

		}
		html_besedilo += "</tr>";
	}

	html_besedilo += "</table>";

	QTextEdit *textedit = new QTextEdit;

	textedit->setHtml(html_besedilo);
	html_besedilo = textedit->toHtml();

	odlozisce->clear();

	QMimeData *mimeData = new QMimeData();
	mimeData->setData("text/html", html_besedilo.toUtf8());
	odlozisce->setMimeData(mimeData, QClipboard::Clipboard);

}
开发者ID:SpelaOman,项目名称:BubiRacun,代码行数:43,代码来源:wid_stranke.cpp


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