本文整理汇总了C++中QTextBrowser::document方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextBrowser::document方法的具体用法?C++ QTextBrowser::document怎么用?C++ QTextBrowser::document使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextBrowser
的用法示例。
在下文中一共展示了QTextBrowser::document方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
/*!
Constructs a new about box on top of given \a parent window.
*/
AboutBox::AboutBox(QWidget * parent) : QDialog(parent)
{
setWindowTitle("About MaxCalc");
tstring labelText = _T("MaxCalc v");
labelText += Constants::VERSION;
labelText += _T(" (");
labelText += _T("built: ");
tstring date = stringToWideString(__DATE__);
labelText += date;
labelText += _T(")<br>");
labelText += Constants::COPYRIGHT;
labelText += _T("<br><a href='");
labelText += Constants::WEBSITE;
labelText += _T("'>");
labelText += Constants::WEBSITE;
labelText += _T("</a>");
QTextBrowser * label = new QTextBrowser;
label->setHtml(QString::fromWCharArray(labelText.c_str()));
label->setOpenExternalLinks(true);
label->setFrameStyle(QFrame::NoFrame);
QPalette p;
p.setColor(QPalette::Base, p.color(QPalette::Background));
label->setPalette(p);
label->setLineWrapMode(QTextEdit::NoWrap);
label->document()->adjustSize();
label->setMinimumSize(label->document()->size().toSize());
label->setMaximumSize(label->document()->size().toSize());
QPushButton * closeButton = new QPushButton;
closeButton->setText(tr("&Close"));
QGridLayout * layout = new QGridLayout;
layout->addWidget(label, 1, 0, 1, -1);
layout->addItem(new QSpacerItem(20, 10, QSizePolicy::Minimum,
QSizePolicy::Fixed), 2, 1, 1, 1);
layout->addItem(new QSpacerItem(20, 20,
QSizePolicy::Expanding), 3, 0, 1, 1);
layout->addWidget(closeButton, 3, 1, 1, 1);
layout->addItem(new QSpacerItem(20, 20,
QSizePolicy::Expanding), 3, 2, 1, 1);
setLayout(layout);
setMaximumSize(sizeHint());
setMinimumSize(sizeHint());
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
}
示例2: prepareErrorPane
void UIDesktopPanePrivate::prepareErrorPane()
{
if (m_pErrBox)
return;
/* Create error pane: */
m_pErrBox = new QWidget;
/* Create main layout: */
QVBoxLayout *pMainLayout = new QVBoxLayout(m_pErrBox);
#if defined(VBOX_WS_MAC)
pMainLayout->setContentsMargins(4, 5, 5, 5);
#elif defined(VBOX_WS_WIN)
pMainLayout->setContentsMargins(3, 5, 5, 0);
#elif defined(VBOX_WS_X11)
pMainLayout->setContentsMargins(0, 5, 5, 5);
#endif
pMainLayout->setSpacing(10);
/* Create error label: */
m_pErrLabel = new QLabel(m_pErrBox);
m_pErrLabel->setWordWrap(true);
m_pErrLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
pMainLayout->addWidget(m_pErrLabel);
/* Create error text-browser: */
m_pErrText = new QTextBrowser(m_pErrBox);
m_pErrText->setFocusPolicy(Qt::StrongFocus);
m_pErrText->document()->setDefaultStyleSheet("a { text-decoration: none; }");
pMainLayout->addWidget(m_pErrText);
/* If refresh action was set: */
if (m_pRefreshAction)
{
/* Create refresh button: */
m_pRefreshButton = new QToolButton(m_pErrBox);
m_pRefreshButton->setFocusPolicy(Qt::StrongFocus);
/* Create refresh button layout: */
QHBoxLayout *pButtonLayout = new QHBoxLayout;
pMainLayout->addLayout(pButtonLayout);
pButtonLayout->addStretch();
pButtonLayout->addWidget(m_pRefreshButton);
/* Connect refresh button: */
connect(m_pRefreshButton, SIGNAL(clicked()), m_pRefreshAction, SIGNAL(triggered()));
}
pMainLayout->addStretch();
/* Add into the stack: */
addWidget(m_pErrBox);
/* Retranslate finally: */
retranslateUi();
}
示例3: main
int main(int argc, char **argv)
{
QApplication app(argc, argv);
//! [0]
QTextBrowser browser;
QColor linkColor(Qt::red);
QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name());
browser.document()->setDefaultStyleSheet(sheet);
//! [0]
browser.setSource(QUrl("../../../html/index.html"));
browser.resize(800, 600);
browser.show();
return app.exec();
}
示例4: doFind
void FindDialog::doFind(bool forward)
{
QTextBrowser *browser = static_cast<QTextBrowser*>(mainWindow()->browsers()->currentBrowser());
sb->clearMessage();
if (ui.comboFind->currentText() != findExpr || lastBrowser != browser)
onceFound = false;
findExpr = ui.comboFind->currentText();
QTextDocument::FindFlags flags = 0;
if (ui.checkCase->isChecked())
flags |= QTextDocument::FindCaseSensitively;
if (ui.checkWords->isChecked())
flags |= QTextDocument::FindWholeWords;
QTextCursor c = browser->textCursor();
if (!c.hasSelection()) {
if (forward)
c.movePosition(QTextCursor::Start);
else
c.movePosition(QTextCursor::End);
browser->setTextCursor(c);
}
QTextDocument::FindFlags options;
if (forward == false)
flags |= QTextDocument::FindBackward;
QTextCursor found = browser->document()->find(findExpr, c, flags);
if (found.isNull()) {
if (onceFound) {
if (forward)
statusMessage(tr("Search reached end of the document"));
else
statusMessage(tr("Search reached start of the document"));
} else {
statusMessage(tr( "Text not found" ));
}
} else {
browser->setTextCursor(found);
}
onceFound |= !found.isNull();
lastBrowser = browser;
}
示例5: findHelper
void FindEditor::findHelper(FindOption *opt)
{
bool bFocus = m_findEdit->hasFocus();
LiteApi::IEditor *editor = m_liteApp->editorManager()->currentEditor();
if (!editor) {
return;
}
LiteApi::ITextEditor *textEditor = LiteApi::getTextEditor(editor);
QTextCursor find;
if (textEditor) {
QPlainTextEdit *ed = LiteApi::getPlainTextEdit(editor);
if (ed) {
find = findEditor(ed->document(),ed->textCursor(),opt);
if (!find.isNull()) {
ed->setTextCursor(find);
}
}
} else {
QTextBrowser *ed = LiteApi::findExtensionObject<QTextBrowser*>(editor,"LiteApi.QTextBrowser");
if (ed) {
find = findEditor(ed->document(),ed->textCursor(),opt);
if (!find.isNull()) {
ed->setTextCursor(find);
}
}
}
if (find.isNull()) {
m_status->setText(tr("Not find"));
} else {
m_status->setText(QString("Ln:%1 Col:%2").
arg(find.blockNumber()+1).
arg(find.columnNumber()+1));
}
if (bFocus) {
m_findEdit->setFocus();
} else if (textEditor) {
textEditor->onActive();
}
}
示例6: showLog
/*!
Shows the application log.
\todo Write some sort of log viewer.
*/
void MvdMainWindow::showLog()
{
QFileInfo fi(paths().logFile());
QFile file(fi.absoluteFilePath());
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::warning(this, MVD_CAPTION, tr("Failed to open the log file."));
return;
}
QTextBrowser *viewer = new QTextBrowser;
viewer->setWindowFlags(Qt::Tool);
viewer->setWindowModality(Qt::NonModal);
viewer->resize(640, 480);
new MvdLogSyntaxHighlighter(viewer->document());
QTextStream stream(&file);
QString text = stream.readAll();
viewer->setPlainText(text);
viewer->show();
}