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


C++ QTextBrowser类代码示例

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


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

示例1: QString

void FileViewer::on_grabfile_clicked()
{

     //uses name input as arguments for path
    QString location = QString("C:/Users/Mike/Documents/Patients/%1_%2")
                   .arg(first->text())
                   .arg(last->text());

    //FILES//

    //filtering for txt files//
    QStringList textFilter;
    textFilter << "*.txt";

    //opens directory at location, with filter//
    QDir dir(location);

    QFileInfoList textlist = dir.entryInfoList(textFilter, QDir::Files);

    //--actions for each txt file--//
    foreach(QFileInfo f, textlist){

        QString g = f.filePath();    //gets filename
        QFile thisfile(g);           //sets file for filename
        if(!thisfile.open(QIODevice::ReadOnly))
            QMessageBox::information(0,"info",thisfile.errorString()); //creates error message if can't open file
        QTextStream in(&thisfile);                                     //grabs text from file

        QTextBrowser *browser = new QTextBrowser;  //creates textbrowser for file text to display
        browser->setText(in.readAll());            //sets text of textbrowser to file text

        tabWidget->addTab(browser,tr("Doc"));      //adds tab with browser inside, displaying text
    }
开发者ID:caleb92,项目名称:RhinoApp2,代码行数:33,代码来源:fileviewer.cpp

示例2: getImage

static QImage getImage(QTextDocument *doc, const QTextImageFormat &format)
{
    QImage image;

    QString name = format.name();
    if (name.startsWith(QLatin1String(":/"))) // auto-detect resources
        name.prepend(QLatin1String("qrc"));
    QUrl url = QUrl::fromEncoded(name.toUtf8());
    const QVariant data = doc->resource(QTextDocument::ImageResource, url);
    if (data.type() == QVariant::Image) {
        image = qvariant_cast<QImage>(data);
    } else if (data.type() == QVariant::ByteArray) {
        image.loadFromData(data.toByteArray());
    }

    if (image.isNull()) {
        QString context;
#ifndef QT_NO_TEXTBROWSER
        QTextBrowser *browser = qobject_cast<QTextBrowser *>(doc->parent());
        if (browser)
            context = browser->source().toString();
#endif
        if (QTextImageHandler::externalLoader)
            image = QTextImageHandler::externalLoader(name, context);

        if (image.isNull()) { // try direct loading
            name = format.name(); // remove qrc:/ prefix again
            if (name.isEmpty() || !image.load(name))
                return QImage(QLatin1String(":/trolltech/styles/commonstyle/images/file-16.png"));
        }
        doc->addResource(QTextDocument::ImageResource, url, image);
    }

    return image;
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:35,代码来源:qtextimagehandler.cpp

示例3: setup

  virtual int setup() {
    QTextBrowser *qw;
    uint32_t flags;
    GWEN_WIDGET *wParent;
    QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
    QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
    const char *s;
    QString text;

    flags=GWEN_Widget_GetFlags(_widget);
    wParent=GWEN_Widget_Tree_GetParent(_widget);
    s=GWEN_Widget_GetText(_widget, 0);
    if (s)
      text=QString::fromUtf8(s);

    qw=new QTextBrowser();
    qw->setText(text);

    /* handle flags */
    if (flags & GWEN_WIDGET_FLAGS_FILLX)
      hpolicy=QSizePolicy::Expanding;
    if (flags & GWEN_WIDGET_FLAGS_FILLY)
      vpolicy=QSizePolicy::Expanding;
    qw->setSizePolicy(hpolicy, vpolicy);

    GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_REAL, (void*) qw);

    if (wParent)
      GWEN_Widget_AddChildGuiWidget(wParent, _widget);
    return 0;
  }
开发者ID:Zauberstuhl,项目名称:gwenhywfar,代码行数:31,代码来源:w_textbrowser.cpp

示例4: html

QWidget* AboutBox::createContributorsPanel()
{
	QString html(tr(""
	"<h2>Contributors</h2>"
	"<p>"
	"The following people have given their time and talent to help support the GLE/QGLE effort (in alphabetical order)."
	"</p>"
	""
	"<ul>"
	"<li>A. S. Budden: programming (QGLE), packager for Arch Linux</li>"
	"<li>Andrey G. Grozin: packager for Gentoo Linux</li>"
	"<li>Axel Rohde: 3.3f-h versions (these were 32 bit DOS and OS/2 ports)</li>"
	"<li>Bryn Jeffries: programming (Linux)</li>"
	"<li>Chris Pugmire: original program creation and design</li>"
	"<li>Christoph Brendes: programming</li>"
	"<li>David Parfitt: documentation (GLE users guide)</li>"
	"<li>Edd Edmondson: packager for Mac OS/X"
	"<li>Jan Struyf: programming (and current 4.x series maintainer)</li>"
	"<li>Laurence Abbott: programming</li>"
	"<li>Michal Vyskocil: packager for openSUSE</li>"
	"<li>Stephen Blundell: documentation (GLE users guide)</li>"
	"<li>Steve Wilkinson: programming (user interface)</li>"
	"<li>Terje R&oslash;sten: packager for Fedora Core</li>"
	"<li>Vincent LaBella: resurrected 3.3h to GLE 4.0 C++ code base</li>"
	"<li>Zbigniew Kisiel: testing</li>"
	"</ul>"
	"<p>&nbsp;</p>"
	""));
	QTextBrowser* label = new QTextBrowser();
	label->setOpenLinks(false);
	label->setHtml(html);
	return label;
}
开发者ID:pnkfelix,项目名称:glx-gle,代码行数:33,代码来源:about.cpp

示例5: b

void ViewHelpMenu::showLicense()
{  
  QDialog b(this,Qt::Tool);
  b.setModal(true);
  QPixmap logo = ViewerIcon::getPixmap( "gnu.png");
  QLabel * llogo = new QLabel(&b);
  llogo->setGeometry(QRect(QPoint(0,0),logo.size()));
  llogo->setPixmap(logo);
  b.setMinimumSize(QSize(logo.width()*4,logo.height()));
  b.setWindowTitle("License");
  QTextBrowser * lictext = new QTextBrowser(&b);
  QFont f("Courrier", 8);
  lictext->setFont( f );
  lictext->setGeometry(QRect(logo.width(),0,logo.width()*3,logo.height()));
  // lictext->setHScrollBarMode(QScrollView::AlwaysOff);
  lictext->setLineWidth(0);
  /* QPalette pal = lictext->palette();
  QColorGroup c = pal.active();
  c.setColor(QColorGroup::Background,QColor(255,255,255));
  pal.setActive(c);
  lictext->setPalette(pal);*/
  QString copyright((TOOLS(getPlantGLDir())+"/share/plantgl/LICENSE").c_str());
  if(QFileInfo(copyright).exists() ) 
	  lictext->setSource(copyright);
  QSize s = qApp->desktop()->size();
  s = s - b.size();
  s /= 2;
  b.move(s.width(),s.height()); 
  b.exec();
}
开发者ID:kkremitzki,项目名称:plantgl,代码行数:30,代码来源:helpmenu.cpp

示例6: QWidget

QT_BEGIN_NAMESPACE

SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent)
    : QWidget(parent)
    , zoomCount(0)
    , searchEngine(engine)
{
    TRACE_OBJ
    QVBoxLayout *vLayout = new QVBoxLayout(this);

    resultWidget = searchEngine->resultWidget();
    QHelpSearchQueryWidget *queryWidget = searchEngine->queryWidget();

    vLayout->addWidget(queryWidget);
    vLayout->addWidget(resultWidget);

    setFocusProxy(queryWidget);

    connect(queryWidget, SIGNAL(search()), this, SLOT(search()));
    connect(resultWidget, SIGNAL(requestShowLink(QUrl)), this,
        SIGNAL(requestShowLink(QUrl)));

    connect(searchEngine, SIGNAL(searchingStarted()), this,
        SLOT(searchingStarted()));
    connect(searchEngine, SIGNAL(searchingFinished(int)), this,
        SLOT(searchingFinished(int)));

    QTextBrowser* browser = resultWidget->findChild<QTextBrowser*>();
    if (browser) // Will be null if lib was configured not to use CLucene.
        browser->viewport()->installEventFilter(this);
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:31,代码来源:searchwidget.cpp

示例7: QLabel

AboutAppWnd::AboutAppWnd()
{
    QVBoxLayout* layout = new QVBoxLayout;
    layout->setSpacing(0);
    layout->setContentsMargins(0,0,0,0);

    QLabel *label = new QLabel(tr("About Google Translator"));

    QTextBrowser *text = new QTextBrowser(this);
    text->setHtml(
            "<a href=\"http://alexsnet.ru/opensource/translator/\">Google Translator</a> is a native GUI application for "
            "Google Translate Engine.<br />This application is free and open source.<br />"
            "Developers:<ul>"
            "<li>Alex Snet (<a href=\"http://alexsnet.ru\">WWW</a> | <a href=\"mailto:[email protected]\">Mail</a>)</li>"
            "</ul>"
    );
    text->setReadOnly(true);
    text->setOpenExternalLinks(true);

    QPushButton *okBtn = new QPushButton(tr("Ok"),this);
    connect( okBtn, SIGNAL(clicked()), this, SLOT(close()) );

    layout->addWidget( label );
    layout->addWidget( text );
    layout->addWidget( okBtn );
    this->setWindowTitle( tr("About Google Translator") );
    this->setLayout(layout);
}
开发者ID:AlexSnet,项目名称:ASTranslator,代码行数:28,代码来源:aboutappwnd.cpp

示例8: QVBoxLayout

void HelpSearchView::CreateQtPartControl(QWidget* parent)
{
  if (m_ResultWidget == nullptr)
  {
    m_Parent = parent;

    auto   vLayout = new QVBoxLayout(parent);

    // This will be lead to strange behavior when using multiple instances of this view
    // because the QHelpSearchResultWidget instance is shared. The new view will
    // reparent the widget.
    m_ResultWidget = m_SearchEngine->resultWidget();
    m_QueryWidget = new QHelpSearchQueryWidget();

    vLayout->addWidget(m_QueryWidget);
    vLayout->addWidget(m_ResultWidget);

    connect(m_QueryWidget, SIGNAL(search()), this, SLOT(search()));
    connect(m_ResultWidget, SIGNAL(requestShowLink(QUrl)), this,
            SLOT(requestShowLink(QUrl)));

    connect(m_SearchEngine, SIGNAL(searchingStarted()), this,
            SLOT(searchingStarted()));
    connect(m_SearchEngine, SIGNAL(searchingFinished(int)), this,
            SLOT(searchingFinished(int)));

    QTextBrowser* browser = m_ResultWidget->findChild<QTextBrowser*>();
    if (browser) // Will be null if QtHelp was configured not to use CLucene.
    {
      browser->viewport()->installEventFilter(this);
      browser->setContextMenuPolicy(Qt::CustomContextMenu);
      connect(browser, SIGNAL(customContextMenuRequested(QPoint)),
              this, SLOT(showContextMenu(QPoint)));
    }
  }
开发者ID:151706061,项目名称:MITK,代码行数:35,代码来源:berryHelpSearchView.cpp

示例9: QDialog

CWizAboutDialog::CWizAboutDialog(QWidget *parent)
    : QDialog(parent)
{
    QLabel* labelIcon = new QLabel(this);
    labelIcon->setPixmap(qApp->windowIcon().pixmap(QSize(58, 58)));

#if defined Q_OS_MAC
    QString strProduct("<span style=\"font-weight:bold;font-size:14px\">WizNote for Mac</span>");
#elif defined Q_OS_LINUX
    QString strProduct("<span style=\"font-weight:bold;font-size:14px\">WizNote for Linux</span>");
#else
    QString strProduct("<span style=\"font-weight:bold;font-size:14px\">WizNote for Windows</span>");
#endif

    QLabel* labelProduct = new QLabel(this);
    labelProduct->setText(strProduct);

    QFileInfo fi(::WizGetAppFileName());
    QDateTime t = fi.lastModified();
    QString strBuildNumber("(%1.%2.%3 %4:%5)");
    strBuildNumber = strBuildNumber.\
            arg(t.date().year()).\
            arg(t.date().month()).\
            arg(t.date().day()).\
            arg(t.time().hour()).\
            arg(t.time().minute());

    QString strInfo = QString(tr("<span style=\"font-size:11px\">Version %2 %3</span>")).arg(WIZ_CLIENT_VERSION, strBuildNumber);
    QLabel* labelBuild = new QLabel(this);
    labelBuild->setText(strInfo);

    QTextBrowser* textCredits = new QTextBrowser(this);
    textCredits->setOpenExternalLinks(true);

    QString strHtml;
    ::WizLoadUnicodeTextFromFile(":/credits.html", strHtml);
    textCredits->setHtml(strHtml);

    QLabel* labelCopyright = new QLabel(this);
    labelCopyright->setText(tr("<span style=\"font-size:10px\">Copy Right 2013 Wiz inc. All rights reserved</span>"));

    QVBoxLayout* layout = new QVBoxLayout();
    layout->setContentsMargins(0, 10, 0, 10);
    setLayout(layout);

    layout->addWidget(labelIcon);
    layout->addWidget(labelProduct);
    layout->addWidget(labelBuild);
    layout->addWidget(textCredits);
    layout->addWidget(labelCopyright);
    layout->setAlignment(labelIcon, Qt::AlignCenter);
    layout->setAlignment(labelProduct, Qt::AlignCenter);
    layout->setAlignment(labelBuild, Qt::AlignCenter);
    layout->setAlignment(textCredits, Qt::AlignCenter);
    layout->setAlignment(labelCopyright, Qt::AlignCenter);

    setWindowTitle(tr("About WizNote"));
    setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
    setFixedSize(sizeHint());
}
开发者ID:JackChen007,项目名称:WizQTClient,代码行数:60,代码来源:wizAboutDialog.cpp

示例10: show

/*
 * At last we have to just show the retrivied news html
 */
void MainWindow::showDistroNews(QString distroRSSXML, bool searchForLatestNews)
{
  QString html;

  if (distroRSSXML.count() >= 200)
  {
    if (distroRSSXML.at(0)=='*')
    {
      /* If this is an updated RSS, we must warn the user!
       And if the main window is hidden... */
      if (isHidden())
      {
        show();
      }

      ui->twProperties->setTabText(ctn_TABINDEX_NEWS, "** " + StrConstants::getTabNewsName() + " **");
      if (m_gotoNewsTab)
      {
        ui->twProperties->setCurrentIndex(ctn_TABINDEX_NEWS);
      }
    }
    else
    {
      if(searchForLatestNews)
      {
        ui->twProperties->setTabText(ctn_TABINDEX_NEWS, StrConstants::getTabNewsName());
      }
    }

    //First, we have to parse the raw RSS XML...
    html = utils::parseDistroNews();
  }
  else
  {
    if(searchForLatestNews)
      ui->twProperties->setTabText(ctn_TABINDEX_NEWS, StrConstants::getTabNewsName());

    html = distroRSSXML;
  }

  //Now that we have the html table code, let's put it into TextBrowser's News tab
  QTextBrowser *text = ui->twProperties->widget(ctn_TABINDEX_NEWS)->findChild<QTextBrowser*>("textBrowser");
  if (text)
  {
    text->clear();
    text->setHtml(html);
  }

  if (m_gotoNewsTab)
  {
    clearTabOutput();
  }

  if (searchForLatestNews && m_gotoNewsTab)
  {
    changeTabWidgetPropertiesIndex(ctn_TABINDEX_NEWS);
  }

  ui->actionGetNews->setEnabled(true);
}
开发者ID:nbyouri,项目名称:octopkg,代码行数:63,代码来源:mainwindow_news.cpp

示例11: QWidget

LicenseTab::LicenseTab(QWidget *parent)
    : QWidget(parent)
{
    QTextBrowser *license = new QTextBrowser;
    license->setOpenExternalLinks(true);
    license->setFrameShape(QFrame::NoFrame);
    license->setFrameShadow(QFrame::Plain);

    QString gpl = QString(tr(
                              "QIpMsg is free software: you can redistribute it and/or modify"
                              "it under the terms of the GNU General Public License as published by"
                              "the Free Software Foundation, either version 3 of the License, or"
                              "(at your option) any later version."
                              "\n\n"
                              "QIpMsg is distributed in the hope that it will be useful,"
                              "but WITHOUT ANY WARRANTY; without even the implied warranty of"
                              "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"
                              "GNU General Public License for more details."
                              "\n\n"
                              "QIpMsg is distributed in the hope that it will be useful,"
                              "You should have received a copy of the GNU General Public License"
                              "along with QIpMsg.  If not, see <http://www.gnu.org/licenses>."
                          ));

    license->setText(gpl);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(license);

    setLayout(mainLayout);
}
开发者ID:louislevin12,项目名称:qipmsg,代码行数:31,代码来源:about_dialog.cpp

示例12: main

int main(int argc, char ** argv) {
    using Q = QObject;
    QApplication app{argc, argv};
    QWidget ui;
    QVBoxLayout layout{&ui};
    QTextBrowser log;
    QProgressBar bar;
    QPushButton scan{"Scan localhost"};
    layout.addWidget(&log);
    layout.addWidget(&bar);
    layout.addWidget(&scan);
    bar.setRange(1, 65535);
    ui.show();

    Scanner scanner;
    Q::connect(&scan, &QPushButton::clicked, &scanner, [&]{
        scan.setEnabled(false);
        scanner.start();
    });
    Q::connect(&scanner, &Scanner::hasResult, &log, [&](int port, bool isOpen){
        bar.setValue(port);
        if (!isOpen) return;
        auto color = isOpen ? QStringLiteral("green") : QStringLiteral("red");
        auto state = isOpen ? QStringLiteral("open") : QStringLiteral("closed");
        log.append(QStringLiteral("<font color=\"%1\">Port %2 is %3.</font><br/>").
                   arg(color).arg(port).arg(state));
    });
    Q::connect(&scanner, &Scanner::done, &scan, [&]{
        bar.reset();
        scan.setEnabled(true);
    });
    return app.exec();
}
开发者ID:KubaO,项目名称:stackoverflown,代码行数:33,代码来源:main.cpp

示例13: fileHashingFinished

void FriendsDialog::fileHashingFinished(QList<HashedFile> hashedFiles)
{
    std::cerr << "FriendsDialog::fileHashingFinished() started." << std::endl;

    QString mesgString;

    QList<HashedFile>::iterator it;
    for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) {
        HashedFile& hashedFile = *it;
        RetroShareLink link;

        if (!link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId())))
            continue;

        mesgString += link.toHtmlSize();
        if (it!= hashedFiles.end()) {
            mesgString += "<BR>";
        }
    }

#ifdef FRIENDS_DEBUG
    std::cerr << "FriendsDialog::fileHashingFinished mesgString : " << mesgString.toStdString() << std::endl;
#endif

    if (!mesgString.isEmpty()) {
        /* convert to real html document */
        QTextBrowser textBrowser;
        textBrowser.setHtml(mesgString);
        std::wstring msg = textBrowser.toHtml().toStdWString();

        rsMsgs->sendPublicChat(msg);
        setFont();
    }
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例14: dlg

void BatchJob::ShowLog()
{

    QDialog dlg(MIMainWindow::instance());
    dlg.setWindowTitle(logFile);
    dlg.setModal(true);
    dlg.setSizeGripEnabled(true);
    QVBoxLayout *mainLayout = new QVBoxLayout;
    dlg.setLayout(mainLayout);

    QTextBrowser *browse = new QTextBrowser(&dlg);
    mainLayout->addWidget(browse);

    QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dlg);
    mainLayout->addWidget(bb);
    dlg.connect(bb, SIGNAL(accepted()), &dlg, SLOT(accept()));

    QFile logFileObj(logFile);
    if ( !logFileObj.open(QFile::ReadOnly | QFile::Text) )
    {
        browse->setPlainText(QObject::tr("ERROR: Log file %1 not found!")
                             .arg(logFile));
    }
    else
    {
        QTextStream logStream(&logFileObj);
        browse->setPlainText(logStream.readAll());
    }

    dlg.exec();
}
开发者ID:SpiritsThief,项目名称:mifit,代码行数:31,代码来源:BatchJob.cpp

示例15: QDialog

HelpDialog::HelpDialog( QWidget* parent)
    : QDialog( parent )
{
    QVBoxLayout* layout = new QVBoxLayout;
    setLayout( layout );

    QTextBrowser* webView = new QTextBrowser( this );
    layout->addWidget( webView );

    const QString text = tr(
        "<h3>Presentation</h3> \
        This application demonstrates some aspects of the KDAB updater component.<br/> \
        Initially you can add target items (<a href=#L4RAction>Line 4 Receiver</a> or <a href=#PSMAction>PSM</a> devices) that use some current firmware version, to the table. <br/> \
        You can see the current compatibility level and firmware version known to the application in the status bar. The source used for finding updates is available when clicking on the button <a href=#SourcesAction>Update Sources</a>.\
        <h3>Step 1: add some items</h3> \
        Add some items to the table, using the <a href=#L4RAction>Add Line 4 Receiver</a> or <a href=#PSMAction>Add PSM</a> button. \
        <h3>Step 2: update the firmware</h3> \
        Update the firmware information by clicking on the <a href=#UpdateAction>Update</a> button : a dialog appears that lets you download and install the version <b>1.1</b> for the package <b>Firmware</b>.<br/> \
        Once that is done, the status bar is updated with the new firmware version.<br/> \
        To update the devices in the table: <a href=#SelectAllAction>select them all</a> and click on the <a href=#UploadAction>Upload Firmwares</a> button. \
        <h3>Step 3: change the compatibility level</h3> \
        The current compatibility level is <b>1</b>. To change that, click on the <a href=#CompatUpdateAction>Update Compat</a> button : a dialog appears that lets you change to a new compat level <b>2</b>, if updates at that level are available.<br/>\
        Once it's done, the status bar is updated with the new compat level and you should see a new column in the table and the application's style changed.\
        <h3>Step 4: update the firmware (one more time)</h3> \
        Now that you changed the compatibility level, you can update the firmware one more time by clicking on the <a href=#UpdateAction>Update</a> button: a dialog appears that lets you install the version <b>2.0</b> for the package <b>Firmware</b><br/> \
        This update wasn't available the first time because it needs the compatibility level <b>2</b>." );

    webView->setHtml( text );
    connect( webView, SIGNAL(linkClicked(QUrl)),
             this, SLOT(clickLink(QUrl)) );

    setWindowTitle( tr("Help FirmwareDemoHttp") );
    resize( 480, 480 );
}
开发者ID:dbzhang800,项目名称:KDUpdater,代码行数:34,代码来源:helpdialog.cpp


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