本文整理汇总了C++中QLabel::setTextFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::setTextFormat方法的具体用法?C++ QLabel::setTextFormat怎么用?C++ QLabel::setTextFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::setTextFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QVBoxLayout
AboutDialog::AboutDialog() {
setWindowTitle(tr("%1 - About").arg(PROGRAM_NAME));
setAttribute(Qt::WA_DeleteOnClose);
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setSizeConstraint(QLayout::SetFixedSize);
QHBoxLayout *hbox = new QHBoxLayout;
vbox->addLayout(hbox);
QString str = tr(
"<p><font face='Arial' size='20'><b>%1</b></font></p>"
"<p>Copyright 2008-2009 by jlh (<a href='mailto:[email protected]'>[email protected]</a>)<br>"
"Copyright 2010-2011 by Peter Savichev (proton) (<a href='[email protected]'>[email protected]</a>)<br>"
"Version: %2<br>"
"Website: <a href='%3'>%3</a></p>");
str = str.arg(PROGRAM_NAME).arg(recorderVersion).arg(websiteURL);
QLabel *label = new QLabel(str);
label->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
label->setTextFormat(Qt::RichText);
label->setOpenExternalLinks(true);
hbox->addWidget(label, 1, Qt::AlignTop);
label = new QLabel;
label->setPixmap(QPixmap(":/res/tray-red.png"));
hbox->addWidget(label, 0, Qt::AlignTop);
str = tr(
"<hr>"
"<p>This program is free software; you can redistribute it and/or modify it under<br>"
"the terms of the GNU General Public License as published by the <a href='http://www.fsf.org/'>Free<br>"
"Software Foundation</a>; either <a href='http://www.gnu.org/licenses/old-licenses/gpl-2.0.html'>version 2 of the License</a>, "
"<a href='http://www.gnu.org/licenses/gpl.html'>version 3 of the<br>"
"License</a>, or (at your option) any later version.</p>"
"<p>This program is distributed in the hope that it will be useful, but WITHOUT<br>"
"ANY WARRANTY; without even the implied warranty of MERCHANTABILITY<br>"
"or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public<br>"
"License for more details.</p>"
"<hr>"
"<p>This product uses the Skype API but is not endorsed, certified or otherwise<br>"
"approved in any way by Skype.</p>"
"<hr>"
"<p><small>Git commit: %1<br>"
"Build date: %2</small></p>");
str = str.arg(recorderCommit, recorderDate);
label = new QLabel(str);
label->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
label->setTextFormat(Qt::RichText);
label->setOpenExternalLinks(true);
vbox->addWidget(label);
QPushButton *button = new QPushButton(tr("&Close"));
connect(button, SIGNAL(clicked()), this, SLOT(close()));
vbox->addWidget(button);
show();
}
示例2: addFriendRequestWidget
void AddFriendForm::addFriendRequestWidget(const QString &friendAddress, const QString &message)
{
QWidget* friendWidget = new QWidget(tabWidget);
QHBoxLayout* friendLayout = new QHBoxLayout(friendWidget);
QVBoxLayout* horLayout = new QVBoxLayout();
horLayout->setMargin(0);
friendLayout->addLayout(horLayout);
CroppingLabel* friendLabel = new CroppingLabel(friendWidget);
friendLabel->setText("<b>" + friendAddress + "</b>");
horLayout->addWidget(friendLabel);
QLabel* messageLabel = new QLabel(message);
messageLabel->setTextFormat(Qt::PlainText);
messageLabel->setWordWrap(true);
horLayout->addWidget(messageLabel, 1);
QPushButton* acceptButton = new QPushButton(friendWidget);
acceptButtons.append(acceptButton);
connect(acceptButton, &QPushButton::released, this, &AddFriendForm::onFriendRequestAccepted);
friendLayout->addWidget(acceptButton);
retranslateAcceptButton(acceptButton);
QPushButton* rejectButton = new QPushButton(friendWidget);
rejectButtons.append(rejectButton);
connect(rejectButton, &QPushButton::released, this, &AddFriendForm::onFriendRequestRejected);
friendLayout->addWidget(rejectButton);
retranslateRejectButton(rejectButton);
requestsLayout->insertWidget(0, friendWidget);
}
示例3: QLabel
FirstRunDialog::FirstRunDialog() :
IconDialogBase(tr("Information"), QStyle::SP_MessageBoxInformation)
{
QLabel *label = new QLabel(tr(
"<p>Welcome to SkypeRec!</p>"
"<p>Please note that SkypeRec does not have a main window.<br>"
"Instead, it hides itself in the system tray, from where you can open<br>"
"the preferences dialog, start or stop recording your Skype calls, or<br>"
"access previously recorded calls.</p>"
"<p>Thank you for using SkypeRec!</p>"
));
label->setTextFormat(Qt::RichText);
vbox->addWidget(label);
//TODO:
// QWidget *checkBox = new SmartCheckBox("Do not show this information again", preferences.get(Pref::SuppressFirstRunInformation));
// vbox->addWidget(checkBox);
QPushButton *button = new QPushButton("&OK");
button->setDefault(true);
connect(button, SIGNAL(clicked()), this, SLOT(close()));
hbox->addWidget(button, 0, Qt::AlignHCenter);
show();
}
示例4: setWindowIcon
aboutWidget::aboutWidget()
{
setWindowIcon(QIcon("/usr/share/h3cc/icons/h3cc128x128.png"));
setFixedSize(180,260);
QGridLayout *layout = new QGridLayout;
setLayout(layout);
setWindowTitle(tr("About H3C 802.1x Client"));
QLabel *label = new QLabel;
label->setPixmap(QPixmap("/usr/share/h3cc/icons/h3cc128x128.png"));
label->setAlignment(Qt::AlignCenter);
layout->addWidget(label,0,0);
QLabel *despLabel = new QLabel;
despLabel->setTextFormat(Qt::RichText);
despLabel->setText(tr("H3C 802.1x client By <br>"
"lovewilliam AT "
"<font color=\"Red\">S</font>"
"<font color=\"Orange\">D</font>"
"<font color=\"Blue\">U</font>"
"<font color=\"Yellow\">.</font>"
"<font color=\"Green\">S</font>"
"<font color=\"Purple\">C</font>"
"<br>"
"Visit "
"<a href=\"http://www.bigstarstar.tk/\">http://www.bigstarstar.tk</a>"));
despLabel->setAlignment(Qt::AlignCenter);
layout->addWidget(despLabel,1,0);
QPushButton *btnOK = new QPushButton;
btnOK->setText(tr("I Know!:)"));
layout->addWidget(btnOK,2,0);
connect(btnOK,SIGNAL(clicked(bool)),this,SLOT(deleteLater()));
setMaximumHeight(height());
setMaximumWidth(width());
// setMinimumHeight(height());
// setMinimumWidth(width());
}
示例5: HtmlHighlighter
InsertHtmlDialogPrivate( InsertHtmlDialog *qq )
: q( qq )
{
q->setCaption( i18n( "Insert HTML" ) );
q->setButtons( KDialog::Ok|KDialog::Cancel );
q->setButtonText( KDialog::Ok, i18n( "Insert" ) );
QWidget *page = new QWidget( q );
q->setMainWidget( page );
QVBoxLayout *lay = new QVBoxLayout( page );
QLabel *label = new QLabel( i18n( "Insert HTML tags and texts:" ) );
lay->addWidget( label );
editor = new KTextEdit;
new HtmlHighlighter( editor->document() );
editor->setAcceptRichText( false );
editor->setFocus();
lay->addWidget( editor );
label = new QLabel( i18n( "Example: <i> Hello word </i>" ) );
QFont font = label->font();
font.setBold( true );
label->setFont( font );
label->setTextFormat( Qt::PlainText );
lay->addWidget( label );
q->connect( editor, SIGNAL(textChanged()),
q, SLOT(_k_slotTextChanged()) );
q->enableButtonOk( false );
q->resize( 640, 480 );
}
示例6: QFrame
QuickHelp::QuickHelp(QWidget* widget, QPoint pos, QString text)
: QFrame(0, Qt::ToolTip),
widget_(widget),
window_(widget->window())
{
setAttribute(Qt::WA_DeleteOnClose);
widget_->installEventFilter(this);
window_->installEventFilter(this);
QLabel* label = new QLabel;
label->setStyleSheet(
QString("QLabel { background-color: %1; }").arg(label->palette().toolTipBase().color().name())
);
label->setTextFormat(Qt::RichText);
// label->setOpenExternalLinks(true);
label->setText(text);
connect(label, SIGNAL(linkActivated(const QString&)), this, SLOT(openLink(const QString&)));
#ifdef QT_MAC_USE_COCOA
setFrameStyle(QFrame::NoFrame);
#else
setFrameStyle(QFrame::Plain|QFrame::StyledPanel);
#endif
QVBoxLayout* col = new QVBoxLayout;
col->setSpacing(0);
col->setMargin(0);
col->addWidget(label);
setLayout(col);
move(widget->mapToGlobal(pos));
show();
}
示例7: DatabaseImporterConfig
SqlBatchImporterConfig::SqlBatchImporterConfig( QWidget *parent )
: DatabaseImporterConfig( parent )
{
QWidget *gridHolder = new QWidget( this );
QGridLayout *databaseLayout = new QGridLayout( gridHolder );
QLabel *explanationLabel = new QLabel( i18n( "Input file produced by amarokcollectionscanner.<br>"
"See <a href=\"http://community.kde.org/Amarok/Development/BatchMode\">Batch Mode</a>." ), gridHolder );
explanationLabel->setTextFormat( Qt::RichText );
explanationLabel->setAlignment( Qt::AlignHCenter );
explanationLabel->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ); // Don't stretch vertically
QLabel *label = new QLabel( i18n( "Input file" ), gridHolder );
m_inputFilePathInput = new QLineEdit( gridHolder );
QCompleter *completer = new QCompleter( this );
completer->setModel( new QDirModel( completer ) );
m_inputFilePathInput->setCompleter( completer );
m_inputFilePathInput->setText( QDir::homePath() + "/result.xml" );
label->setBuddy( m_inputFilePathInput );
databaseLayout->addWidget( explanationLabel, 0, 0, 1, 2 );
databaseLayout->addWidget( label, 1, 0 );
databaseLayout->addWidget( m_inputFilePathInput, 1, 1 );
gridHolder->setLayout( databaseLayout );
QWidget *spacer = new QWidget( this );
spacer->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
}
示例8: updateMetrics
void WorkoutMetricsSummary::updateMetrics(QStringList &order, QHash<QString,RideMetricPtr> &metrics)
{
int row = 0;
foreach(QString name, order)
{
RideMetricPtr rmp = metrics[name];
if(!metricMap.contains(name))
{
QLabel *label = new QLabel((rmp->name()) + ":");
label->setTextFormat(Qt::RichText);
QLabel *lcd = new QLabel();
metricMap[name] = QPair<QLabel*,QLabel*>(label,lcd);
layout->addWidget(label,metricMap.size(),0);
layout->addWidget(lcd,metricMap.size(),1);
}
QLabel *lcd = metricMap[name].second;
if(name == "time_riding")
{
QTime start (0,0,0);
QTime time = start.addSecs(rmp->value(true));
QString s = time.toString("HH:mm:ss");
//qDebug() << s << " " << time.second();
lcd->setText(s);
}
else
{
lcd->setText(QString::number(rmp->value(true),'f',rmp->precision()) + " " + (rmp->units(true)) );
}
//qDebug() << name << ":" << (int)rmp->value(true);
row++;
}
示例9: fatalMessageReceived
void MessageHandlerWidget::fatalMessageReceived(const QString &app, const QString &message,
const QTime &time, const QStringList &backtrace)
{
if (Endpoint::isConnected() && !qobject_cast<MessageHandlerClient*>(ObjectBroker::object<MessageHandlerInterface*>())) {
// only show on remote side
return;
}
QDialog dlg;
dlg.setWindowTitle(tr("QFatal in %1 at %2").arg(app).arg(time.toString()));
QGridLayout *layout = new QGridLayout;
QLabel *iconLabel = new QLabel;
QIcon icon = dlg.style()->standardIcon(QStyle::SP_MessageBoxCritical, 0, &dlg);
int iconSize = dlg.style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, &dlg);
iconLabel->setPixmap(icon.pixmap(iconSize, iconSize));
iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
layout->addWidget(iconLabel, 0, 0);
QLabel *errorLabel = new QLabel;
errorLabel->setTextFormat(Qt::PlainText);
errorLabel->setWordWrap(true);
errorLabel->setText(message);
layout->addWidget(errorLabel, 0, 1);
QDialogButtonBox *buttons = new QDialogButtonBox;
if (!backtrace.isEmpty()) {
QListWidget *backtraceWidget = new QListWidget;
foreach (const QString &frame, backtrace) {
backtraceWidget->addItem(frame);
}
示例10: PopupWidget
ScriptTerminatorWidget::ScriptTerminatorWidget( const QString &message )
: PopupWidget( 0 )
{
setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
setContentsMargins( 4, 4, 4, 4 );
setMinimumWidth( 26 );
setMinimumHeight( 26 );
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
QPalette p = QToolTip::palette();
setPalette( p );
QLabel *alabel = new QLabel( message, this );
alabel->setWordWrap( true );
alabel->setTextFormat( Qt::RichText );
alabel->setTextInteractionFlags( Qt::TextBrowserInteraction );
alabel->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
alabel->setPalette( p );
KPushButton *button = new KPushButton( i18n( "Terminate" ), this );
button->setPalette(p);;
connect( button, SIGNAL(clicked()), SIGNAL(terminate()) );
button = new KPushButton( KStandardGuiItem::close(), this );
button->setPalette(p);
connect( button, SIGNAL(clicked()), SLOT(hide()) );
reposition();
}
示例11: QDialog
DlgTerminate::DlgTerminate(QWidget *parent) : QDialog(parent)
{
QLabel* lblError = new QLabel(tr("A fatal error ocurred during initialization of <b>Impresario</b>. The application needs to be terminated."));
lblError->setWordWrap(true);
lblError->setTextFormat(Qt::RichText);
QVBoxLayout* groupTextLayout = new QVBoxLayout();
groupTextLayout->addWidget(lblError);
QGroupBox* groupText = new QGroupBox();
groupText->setLayout(groupTextLayout);
QDialogButtonBox* buttonBox = new QDialogButtonBox();
QPushButton* btnTerminate = new QPushButton(QIcon(":/icons/resources/quit.png"),tr("Quit"));
QPushButton* btnAbout = new QPushButton(tr("About..."));
buttonBox->addButton(btnAbout,QDialogButtonBox::HelpRole);
buttonBox->addButton(btnTerminate,QDialogButtonBox::RejectRole);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(groupText);
mainLayout->addWidget(new syslog::WndLogger(),1);
mainLayout->addSpacing(5);
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
setWindowTitle(tr("Impresario"));
setWindowIcon(QIcon(":/icons/resources/impresario.png"));
// set signal handlers
connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(onAbout()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
}
示例12: createPreview
void DlgSettingsExportFormat::createPreview(QGridLayout *layout, int &row)
{
LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createPreview";
QLabel *label = new QLabel (tr ("Preview"));
layout->addWidget (label, row, 0, 1, 3);
// Legend. Padding and margin in rich text do not work so is used for spacing
QLabel *labelLegend = new QLabel;
labelLegend->setTextFormat (Qt::RichText);
QString legendHtml = QString ("<span style=\"background-color: %1\"> Functions </span>"
" "
"<span style=\"background-color: %2\"> Relations </span>")
.arg (COLOR_FUNCTIONS)
.arg (COLOR_RELATIONS);
labelLegend->setText (legendHtml);
layout->addWidget (labelLegend, row++, 1, 1, 2, Qt::AlignRight);
m_editPreview = new QTextEdit;
m_editPreview->setReadOnly (true);
m_editPreview->setWhatsThis (tr ("Preview window shows how current settings affect the exported file.\n\n"
"Functions (shown here in blue) are output first, followed by relations "
"(shown here in green) if any exist."));
m_editPreview->setMinimumHeight (MINIMUM_PREVIEW_HEIGHT);
m_editPreview->document()->setDefaultStyleSheet("div { padding-left: 20px; }");
QPalette p = m_editPreview->palette();
p.setColor (QPalette::Base, QColor (240, 240, 240)); // Replace attention-getting white border by gray
m_editPreview->setPalette (p);
layout->addWidget (m_editPreview, row++, 0, 1, 3);
}
示例13: names
GroupChatForm::GroupChatForm(Group* chatGroup)
: group(chatGroup), inCall{false}
{
nusersLabel = new QLabel();
tabber = new TabCompleter(msgEdit, group);
fileButton->setEnabled(false);
if (group->isAvGroupchat())
{
videoButton->setEnabled(false);
videoButton->setObjectName("grey");
}
else
{
videoButton->setVisible(false);
callButton->setVisible(false);
volButton->setVisible(false);
micButton->setVisible(false);
}
nameLabel->setText(group->getGroupWidget()->getName());
nusersLabel->setFont(Style::getFont(Style::Medium));
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->getPeersCount()));
nusersLabel->setObjectName("statusLabel");
avatar->setPixmap(Style::scaleSvgImage(":/img/group_dark.svg", avatar->width(), avatar->height()), Qt::transparent);
msgEdit->setObjectName("group");
namesListLayout = new FlowLayout(0,5,0);
QStringList names(group->getPeerList());
for (const QString& name : names)
{
QLabel *l = new QLabel(name);
l->setTextFormat(Qt::PlainText);
namesListLayout->addWidget(l);
}
headTextLayout->addWidget(nusersLabel);
headTextLayout->addLayout(namesListLayout);
headTextLayout->addStretch();
nameLabel->setMinimumHeight(12);
nusersLabel->setMinimumHeight(12);
connect(sendButton, SIGNAL(clicked()), this, SLOT(onSendTriggered()));
connect(msgEdit, SIGNAL(enterPressed()), this, SLOT(onSendTriggered()));
connect(msgEdit, &ChatTextEdit::tabPressed, tabber, &TabCompleter::complete);
connect(msgEdit, &ChatTextEdit::keyPressed, tabber, &TabCompleter::reset);
connect(callButton, &QPushButton::clicked, this, &GroupChatForm::onCallClicked);
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
connect(volButton, SIGNAL(clicked()), this, SLOT(onVolMuteToggle()));
connect(nameLabel, &CroppingLabel::textChanged, this, [=](QString text, QString orig)
{if (text != orig) emit groupTitleChanged(group->getGroupId(), text.left(128));} );
setAcceptDrops(true);
}
示例14: createHyperlinkLabel
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QLabel* IssuesDockWidget::createHyperlinkLabel(PipelineMessage msg)
{
QString filterClassName = (msg.getFilterClassName() );
QString filterHumanLabel = (msg.getFilterHumanLabel() );
QString msgPrefix = (msg.getPrefix());
if ( filterClassName.isEmpty() || filterHumanLabel.isEmpty() )
{
if(filterClassName.isEmpty() == false) { return new QLabel(filterClassName); }
else if(filterHumanLabel.isEmpty() == false) { return new QLabel(filterHumanLabel); }
return new QLabel("Unknown Filter Class");
}
QUrl filterURL = DREAM3DHelpUrlGenerator::generateHTMLUrl( filterClassName.toLower() );
QString filterHTMLText("<a href=\"");
filterHTMLText.append(filterURL.toString()).append("\">").append(filterHumanLabel).append("</a>");
QLabel* hyperlinkLabel = new QLabel(filterHTMLText);
hyperlinkLabel->setTextFormat(Qt::RichText);
hyperlinkLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
hyperlinkLabel->setOpenExternalLinks(false);
connect(hyperlinkLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(showFilterHelp(const QString&)));
return hyperlinkLabel;
}
示例15: caFile
WalkmeshManager::WalkmeshManager(QWidget *parent, const QGLWidget *shareWidget) :
QDialog(parent, Qt::Tool),
idFile(0), caFile(0), infFile(0), scriptsAndTexts(0)
{
setWindowTitle(tr("Zones"));
walkmesh = Config::value("OpenGL", true).toBool() ? new WalkmeshWidget(0, shareWidget) : 0;
QWidget *walkmeshWidget = walkmesh ? walkmesh : new QWidget(this);
slider1 = new QSlider(this);
slider2 = new QSlider(this);
slider3 = new QSlider(this);
slider1->setRange(-180, 180);
slider2->setRange(-180, 180);
slider3->setRange(-180, 180);
slider1->setValue(0);
slider2->setValue(0);
slider3->setValue(0);
QLabel *keyInfos = new QLabel(tr("Utilisez les touches directionnelles pour déplacer la caméra."));
keyInfos->setTextFormat(Qt::PlainText);
keyInfos->setWordWrap(true);
QPushButton *resetCamera = new QPushButton(tr("Remettre à 0"));
QCheckBox *showModels = new QCheckBox(tr("Afficher modèles"));
tabWidget = new QTabWidget(this);
tabWidget->addTab(buildCameraPage(), tr("Caméra"));
tabWidget->addTab(buildWalkmeshPage(), tr("Walkmesh"));
tabWidget->addTab(buildGatewaysPage(), tr("Sorties"));
tabWidget->addTab(buildDoorsPage(), tr("Portes"));
tabWidget->addTab(buildArrowPage(), tr("Flèches"));
tabWidget->addTab(buildCameraRangePage(), tr("Limites caméra"));
tabWidget->addTab(buildMiscPage(), tr("Divers"));
tabWidget->setFixedHeight(250);
QGridLayout *layout = new QGridLayout(this);
layout->addWidget(walkmeshWidget, 0, 0, 4, 1);
layout->addWidget(slider1, 0, 1);
layout->addWidget(slider2, 0, 2);
layout->addWidget(slider3, 0, 3);
layout->addWidget(keyInfos, 1, 1, 1, 3);
layout->addWidget(resetCamera, 2, 1, 1, 3);
layout->addWidget(showModels, 3, 1, 1, 3);
layout->addWidget(tabWidget, 4, 0, 1, 4);
if(walkmesh) {
connect(slider1, SIGNAL(valueChanged(int)), walkmesh, SLOT(setXRotation(int)));
connect(slider2, SIGNAL(valueChanged(int)), walkmesh, SLOT(setYRotation(int)));
connect(slider3, SIGNAL(valueChanged(int)), walkmesh, SLOT(setZRotation(int)));
connect(resetCamera, SIGNAL(clicked()), SLOT(resetCamera()));
connect(showModels, SIGNAL(toggled(bool)), SLOT(setModelsVisible(bool)));
showModels->setChecked(true);
}
}