本文整理汇总了C++中setTextFormat函数的典型用法代码示例。如果您正苦于以下问题:C++ setTextFormat函数的具体用法?C++ setTextFormat怎么用?C++ setTextFormat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setTextFormat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMessageBox
HelpMessageBox::HelpMessageBox(QWidget *parent) :
QMessageBox(parent)
{
header = tr("Whistle-Qt") + " " + tr("version") + " " +
QString::fromStdString(FormatFullVersion()) + "\n\n" +
tr("Usage:") + "\n" +
" Whistle-qt [" + tr("command-line options") + "] " + "\n";
coreOptions = QString::fromStdString(HelpMessage());
uiOptions = tr("UI options") + ":\n" +
" -lang=<lang> " + tr("Set language, for example \"de_DE\" (default: system locale)") + "\n" +
" -min " + tr("Start minimized") + "\n" +
" -splash " + tr("Show splash screen on startup (default: 1)") + "\n";
setWindowTitle(tr("Whistle-Qt"));
setTextFormat(Qt::PlainText);
// setMinimumWidth is ignored for QMessageBox so put in non-breaking spaces to make it wider.
setText(header + QString(QChar(0x2003)).repeated(50));
setDetailedText(coreOptions + "\n" + uiOptions);
}
示例2: QMessageBox
HelpMessageBox::HelpMessageBox(QWidget *parent) :
QMessageBox(parent)
{
setStyleSheet("background: url(:/images/res/images/dialogBackground.jpg); background-attachment: fixed; color: #ffaa00; selection-background-color: rgb(255, 170, 0, 145); selection-color: white; font-family: Plantagenet Cherokee; font-size: 14px;");
header = tr("Netcoin-Qt") + " " + tr("version") + " " +
QString::fromStdString(FormatFullVersion()) + "\n\n" +
tr("Usage:") + "\n" +
" netcoin-qt [" + tr("command-line options") + "] " + "\n";
coreOptions = QString::fromStdString(HelpMessage());
uiOptions = tr("UI options") + ":\n" +
" -lang=<lang> " + tr("Set language, for example \"de_DE\" (default: system locale)") + "\n" +
" -min " + tr("Start minimized") + "\n" +
" -splash " + tr("Show splash screen on startup (default: 1)") + "\n";
setWindowTitle(tr("Netcoin-Qt"));
setTextFormat(Qt::PlainText);
// setMinimumWidth is ignored for QMessageBox so put in non-breaking spaces to make it wider.
setText(header + QString(QChar(0x2003)).repeated(50));
setDetailedText(coreOptions + "\n" + uiOptions);
}
示例3: QUrl
void LocationBar::refreshTextFormat()
{
if (!m_webView) {
return;
}
TextFormat textFormat;
const QString hostName = m_webView->url().isEmpty() ? QUrl(text()).host() : m_webView->url().host();
if (!hostName.isEmpty()) {
const int hostPos = text().indexOf(hostName);
if (hostPos > 0) {
QTextCharFormat format;
format.setForeground(Colors::mid(palette().color(QPalette::Base), palette().color(QPalette::Text), 1, 1));
QTextLayout::FormatRange schemePart;
schemePart.start = 0;
schemePart.length = hostPos;
schemePart.format = format;
QTextLayout::FormatRange hostPart;
hostPart.start = hostPos;
hostPart.length = hostName.size();
QTextLayout::FormatRange remainingPart;
remainingPart.start = hostPos + hostName.size();
remainingPart.length = text().size() - remainingPart.start;
remainingPart.format = format;
textFormat.append(schemePart);
textFormat.append(hostPart);
textFormat.append(remainingPart);
}
}
setTextFormat(textFormat);
}
示例4: Q3TextEdit
QEditor::QEditor( QWidget* parent, const char* name )
: Q3TextEdit( parent, name )
{
getDocument()->setUseFormatCollection( FALSE );
parenMatcher = new ParenMatcher();
m_currentLine = -1;
getDocument()->addSelection( ParenMatcher::Match );
getDocument()->addSelection( ParenMatcher::Mismatch );
getDocument()->setSelectionColor( ParenMatcher::Match, QColor( 204, 232, 195 ) );
getDocument()->setSelectionColor( ParenMatcher::Mismatch, Qt::magenta );
//document()->setInvertSelectionText( ParenMatcher::Match, FALSE );
//document()->setInvertSelectionText( ParenMatcher::Mismatch, FALSE );
getDocument()->addSelection( sel0 );
getDocument()->setSelectionColor( sel0, QColor( 204, 232, 195 ) );
getDocument()->addSelection( sel1 );
getDocument()->setSelectionColor( sel1, QColor( 204, 207, 255 ) );
setLanguage("c++");
setTabStop(2);
setWordWrap(Q3TextEdit::NoWrap);
setTextFormat(Qt::PlainText);
//connect( this, SIGNAL(cursorPositionChanged(QTextCursor*) ),
// this, SLOT(doMatch(QTextCursor*)) );
// connect( this, SIGNAL(cursorPositionChanged(int, int) ),
// this, SLOT(slotCursorPositionChanged(int, int)) );
}
示例5: DCOPObject
CvsProcessWidget::CvsProcessWidget( CvsService_stub *service, CvsServicePart *part, QWidget *parent, const char *name )
: DCOPObject( "CvsProcessWidgetDCOPIface" ),
QTextEdit( parent, name ),
m_part( part ), m_service( service ), m_job( 0 )
{
setReadOnly( true );
setTextFormat( Qt::LogText );
QStyleSheetItem *style = 0;
style = new QStyleSheetItem( styleSheet(), "goodtag" );
style->setColor( "black" );
style = new QStyleSheetItem( styleSheet(), "errortag" );
style->setColor( "red" );
style->setFontWeight( QFont::Bold );
style = new QStyleSheetItem( styleSheet(), "infotag" );
style->setColor( "blue" );
style = new QStyleSheetItem( styleSheet(), "cvs_conflict" );
style->setColor( "red" );
style = new QStyleSheetItem( styleSheet(), "cvs_added" );
style->setColor( "green" );
style = new QStyleSheetItem( styleSheet(), "cvs_removed" );
style->setColor( "yellow" );
style = new QStyleSheetItem( styleSheet(), "cvs_updated" );
style->setColor( "lightblue" );
style = new QStyleSheetItem( styleSheet(), "cvs_modified" );
style->setColor( "darkgreen" );
style = new QStyleSheetItem( styleSheet(), "cvs_unknown" );
style->setColor( "gray" );
}
示例6: qSort
void GameWidget::endGame()
{
if (m_score >= m_scores.last().score)
{
QString name = QInputDialog::getText(this, "Happy Cube Space Invaders!",
"<b style=\"font-size:24pt\">What is your name ?!");
m_scores.append(Score(name, m_score));
qSort(m_scores);
m_scores.removeLast();
saveScores();
}
setTextFormat(Qt::RichText);
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
QString msg("<font face=\"Courier\"><b style=\"font-size:72pt\">Game Over!</b><br><b style=\"font-size:24pt\">");
for (TScoreList::const_iterator it = m_scores.constBegin(); it != m_scores.constEnd(); ++it)
{
msg += QString("%1.......%2<br>").arg(it->name, -22, '.').arg(humanCount(it->score).c_str(), 13, QChar('.'));
}
msg += "</font>";
setText(msg);
}
示例7: setTextFormat
void QgsFontButton::dropEvent( QDropEvent *e )
{
//is dropped data valid format data?
QColor mimeColor;
QgsTextFormat format;
QFont font;
bool hasAlpha = false;
if ( mMode == ModeTextRenderer && formatFromMimeData( e->mimeData(), format ) )
{
setTextFormat( format );
QgsFontUtils::addRecentFontFamily( mFormat.font().family() );
return;
}
else if ( mMode == ModeQFont && fontFromMimeData( e->mimeData(), font ) )
{
QgsFontUtils::addRecentFontFamily( font.family() );
setCurrentFont( font );
return;
}
else if ( mMode == ModeTextRenderer && colorFromMimeData( e->mimeData(), mimeColor, hasAlpha ) )
{
//accept drop and set new color
e->acceptProposedAction();
if ( hasAlpha )
{
mFormat.setOpacity( mimeColor.alphaF() );
}
mimeColor.setAlphaF( 1.0 );
mFormat.setColor( mimeColor );
QgsRecentColorScheme::addRecentColor( mimeColor );
updatePreview();
emit changed();
}
updatePreview();
}
示例8: QLabel
QtElidingLabel::QtElidingLabel(const QString& text, QWidget* parent, Qt::WindowFlags f) : QLabel(text, parent, f) {
fullText_ = text;
dirty_ = true;
setSizes();
setTextFormat(Qt::PlainText);
}
示例9: setTextFormat
void SkLabel::setText (const QString &text, Qt::TextFormat format)
{
setTextFormat (format);
setText (text);
}
示例10: QTextEdit
ScriptEdit::ScriptEdit(ScriptingEnv *env, QWidget *parent, const char *name)
: QTextEdit(parent, name), scripted(env), d_error(false), d_completer(0),
d_file_name(QString::null), d_search_string(QString::null)
{
myScript = scriptEnv->newScript("", this, name);
connect(myScript, SIGNAL(error(const QString&, const QString&, int)), this, SLOT(insertErrorMsg(const QString&)));
connect(myScript, SIGNAL(print(const QString&)), this, SLOT(scriptPrint(const QString&)));
setLineWrapMode(NoWrap);
setUndoRedoEnabled(true);
setTextFormat(Qt::PlainText);
setAcceptRichText (false);
#ifdef SCRIPTING_PYTHON
if (scriptEnv->name() == QString("Python"))
d_highlighter = new PythonSyntaxHighlighter(this);
else
d_highlighter = NULL;
#endif
d_fmt_default.setBackground(palette().brush(QPalette::Base));
printCursor = textCursor();
scriptsDirPath = qApp->applicationDirPath();
actionExecute = new QAction(tr("E&xecute"), this);
actionExecute->setShortcut( tr("Ctrl+J") );
connect(actionExecute, SIGNAL(activated()), this, SLOT(execute()));
actionExecuteAll = new QAction(tr("Execute &All"), this);
actionExecuteAll->setShortcut( tr("Ctrl+Shift+J") );
connect(actionExecuteAll, SIGNAL(activated()), this, SLOT(executeAll()));
actionEval = new QAction(tr("&Evaluate Expression"), this);
actionEval->setShortcut( tr("Ctrl+Return") );
connect(actionEval, SIGNAL(activated()), this, SLOT(evaluate()));
actionPrint = new QAction(QPixmap(fileprint_xpm), tr("&Print"), this);
connect(actionPrint, SIGNAL(activated()), this, SLOT(print()));
actionImport = new QAction(tr("&Import..."), this);
actionImport->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_O));
connect(actionImport, SIGNAL(activated()), this, SLOT(importASCII()));
QShortcut *accelImport = new QShortcut(actionImport->shortcut(), this);
connect(accelImport, SIGNAL(activated()), this, SLOT(importASCII()));
actionSave = new QAction(QPixmap(filesave_xpm), tr("&Save"), this);
actionSave->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_S));
connect(actionSave, SIGNAL(activated()), this, SLOT(save()));
QShortcut *accelSave = new QShortcut(actionSave->shortcut(), this);
connect(accelSave, SIGNAL(activated()), this, SLOT(save()));
actionExport = new QAction(QIcon(QPixmap(filesaveas_xpm)), tr("Sa&ve as..."), this);
connect(actionExport, SIGNAL(activated()), this, SLOT(exportASCII()));
actionFind = new QAction(QPixmap(find_xpm), tr("&Find..."), this);
actionFind->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_F));
connect(actionFind, SIGNAL(activated()), this, SLOT(showFindDialog()));
QShortcut *accelFind = new QShortcut(actionFind->shortcut(), this);
connect(accelFind, SIGNAL(activated()), this, SLOT(showFindDialog()));
actionReplace = new QAction(tr("&Replace..."), this);
actionReplace->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_R));
connect(actionReplace, SIGNAL(activated()), this, SLOT(replace()));
QShortcut *accelReplace = new QShortcut(actionReplace->shortcut(), this);
connect(accelReplace, SIGNAL(activated()), this, SLOT(replace()));
actionFindNext = new QAction(tr("&Find next"), this);
actionFindNext->setShortcut(QKeySequence(Qt::Key_F3));
connect(actionFindNext, SIGNAL(activated()), this, SLOT(findNext()));
QShortcut *accelFindNext = new QShortcut(actionFindNext->shortcut(), this);
connect(accelFindNext, SIGNAL(activated()), this, SLOT(findNext()));
actionFindPrevious = new QAction(tr("&Find previous"), this);
actionFindPrevious->setShortcut(QKeySequence(Qt::Key_F4));
connect(actionFindPrevious, SIGNAL(activated()), this, SLOT(findPrevious()));
QShortcut *accelFindPrevious = new QShortcut(actionFindPrevious->shortcut(), this);
connect(accelFindPrevious, SIGNAL(activated()), this, SLOT(findPrevious()));
functionsMenu = new QMenu(this);
Q_CHECK_PTR(functionsMenu);
connect(functionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(insertFunction(QAction *)));
}
示例11: QTextEdit
ScriptEdit::ScriptEdit(ScriptingEnv *env, QWidget *parent, const char *name)
: QTextEdit(parent, name), scripted(env), d_error(false), d_completer(0), d_highlighter(0),
d_file_name(QString::null), d_search_string(QString::null), d_output_widget(NULL)
{
myScript = scriptEnv->newScript("", this, name);
connect(myScript, SIGNAL(error(const QString&, const QString&, int)), this, SLOT(insertErrorMsg(const QString&)));
connect(myScript, SIGNAL(print(const QString&)), this, SLOT(scriptPrint(const QString&)));
connect(myScript, SIGNAL(error(const QString&, const QString&, int)),
this, SIGNAL(error(const QString&, const QString&, int)));
setLineWrapMode(NoWrap);
setUndoRedoEnabled(true);
setTextFormat(Qt::PlainText);
setAcceptRichText (false);
setFocusPolicy(Qt::StrongFocus);
rehighlight();
d_fmt_default.setBackground(palette().brush(QPalette::Base));
//Init completer based on parser built-in functions
QStringList functions = MyParser::functionNamesList();
functions.sort();
QCompleter *completer = new QCompleter(this);
completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
completer->setCompletionMode(QCompleter::PopupCompletion);
completer->setModel(new QStringListModel(functions, completer));
setCompleter(completer);
printCursor = textCursor();
scriptsDirPath = qApp->applicationDirPath();
actionExecute = new QAction(tr("E&xecute"), this);
actionExecute->setShortcut( tr("Ctrl+J") );
connect(actionExecute, SIGNAL(activated()), this, SLOT(execute()));
actionExecuteAll = new QAction(QIcon(":/play.png"), tr("Execute &All"), this);
actionExecuteAll->setShortcut( tr("Ctrl+Shift+J") );
connect(actionExecuteAll, SIGNAL(activated()), this, SLOT(executeAll()));
actionEval = new QAction(tr("&Evaluate Expression"), this);
actionEval->setShortcut( tr("Ctrl+Return") );
connect(actionEval, SIGNAL(activated()), this, SLOT(evaluate()));
actionPrint = new QAction(QIcon(":/fileprint.png"), tr("&Print"), this);
connect(actionPrint, SIGNAL(activated()), this, SLOT(print()));
actionImport = new QAction(QIcon(":/fileopen.png"), tr("&Import..."), this);
actionImport->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_O));
connect(actionImport, SIGNAL(activated()), this, SLOT(importASCII()));
actionSave = new QAction(QIcon(":/filesave.png"), tr("&Save"), this);
actionSave->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_S));
connect(actionSave, SIGNAL(activated()), this, SLOT(save()));
actionExport = new QAction(QIcon(":/filesaveas.png"), tr("Sa&ve as..."), this);
connect(actionExport, SIGNAL(activated()), this, SLOT(exportASCII()));
actionFind = new QAction(QIcon(":/find.png"), tr("&Find..."), this);
actionFind->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_F));
connect(actionFind, SIGNAL(activated()), this, SLOT(showFindDialog()));
actionReplace = new QAction(QIcon(":/replace.png"), tr("&Replace..."), this);
actionReplace->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_R));
connect(actionReplace, SIGNAL(activated()), this, SLOT(replace()));
actionFindNext = new QAction(QIcon(":/find_next.png"), tr("&Find next"), this);
actionFindNext->setShortcut(QKeySequence(Qt::Key_F3));
connect(actionFindNext, SIGNAL(activated()), this, SLOT(findNext()));
actionFindPrevious = new QAction(QIcon(":/find_previous.png"), tr("&Find previous"), this);
actionFindPrevious->setShortcut(QKeySequence(Qt::Key_F4));
connect(actionFindPrevious, SIGNAL(activated()), this, SLOT(findPrevious()));
functionsMenu = new QMenu(this);
Q_CHECK_PTR(functionsMenu);
connect(functionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(insertFunction(QAction *)));
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(matchParentheses()));
}
示例12: QLabel
OptionsDialogHeader::OptionsDialogHeader(const QString &ACaption, QWidget *AParent) : QLabel(AParent)
{
setTextFormat(Qt::RichText);
setText(QString("<h2>%1</h2>").arg(ACaption.toHtmlEscaped()));
}
示例13: QWidgetAction
void QgsFontButton::prepareMenu()
{
//we need to tear down and rebuild this menu every time it is shown. Otherwise the space allocated to any
//QgsColorSwatchGridAction is not recalculated by Qt and the swatch grid may not be the correct size
//for the number of colors shown in the grid. Note that we MUST refresh color swatch grids every time this
//menu is opened, otherwise color schemes like the recent color scheme grid are meaningless
mMenu->clear();
QWidgetAction *sizeAction = new QWidgetAction( mMenu );
QWidget *sizeWidget = new QWidget();
QVBoxLayout *sizeLayout = new QVBoxLayout();
sizeLayout->setMargin( 0 );
sizeLayout->setContentsMargins( 0, 0, 0, 3 );
sizeLayout->setSpacing( 2 );
QString fontHeaderLabel;
switch ( mMode )
{
case ModeTextRenderer:
fontHeaderLabel = tr( "Font size (%1)" ).arg( QgsUnitTypes::toString( mFormat.sizeUnit() ) );
break;
case ModeQFont:
fontHeaderLabel = tr( "Font size (pt)" );
break;
}
QgsMenuHeader *sizeLabel = new QgsMenuHeader( fontHeaderLabel );
sizeLayout->addWidget( sizeLabel );
QgsDoubleSpinBox *sizeSpin = new QgsDoubleSpinBox( nullptr );
sizeSpin->setDecimals( 4 );
sizeSpin->setMaximum( 1e+9 );
sizeSpin->setShowClearButton( false );
sizeSpin->setValue( mMode == ModeTextRenderer ? mFormat.size() : mFont.pointSizeF() );
connect( sizeSpin, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ),
this, [ = ]( double value )
{
switch ( mMode )
{
case ModeTextRenderer:
mFormat.setSize( value );
break;
case ModeQFont:
mFont.setPointSizeF( value );
break;
}
updatePreview();
emit changed();
} );
QHBoxLayout *spinLayout = new QHBoxLayout();
spinLayout->setMargin( 0 );
spinLayout->setContentsMargins( 4, 0, 4, 0 );
spinLayout->addWidget( sizeSpin );
sizeLayout->addLayout( spinLayout );
sizeWidget->setLayout( sizeLayout );
sizeAction->setDefaultWidget( sizeWidget );
sizeWidget->setFocusProxy( sizeSpin );
sizeWidget->setFocusPolicy( Qt::StrongFocus );
mMenu->addAction( sizeAction );
QMenu *recentFontMenu = new QMenu( tr( "Recent fonts" ), mMenu );
Q_FOREACH ( const QString &family, QgsFontUtils::recentFontFamilies() )
{
QAction *fontAction = new QAction( family, recentFontMenu );
QFont f = fontAction->font();
f.setFamily( family );
fontAction->setFont( f );
fontAction->setToolTip( family );
recentFontMenu->addAction( fontAction );
if ( ( mMode == ModeTextRenderer && family == mFormat.font().family() )
|| ( mMode == ModeQFont && family == mFont.family() ) )
{
fontAction->setCheckable( true );
fontAction->setChecked( true );
}
auto setFont = [this, family]
{
switch ( mMode )
{
case ModeTextRenderer:
{
QgsTextFormat newFormat = mFormat;
QFont f = newFormat.font();
f.setFamily( family );
newFormat.setFont( f );
setTextFormat( newFormat );
QgsFontUtils::addRecentFontFamily( mFormat.font().family() );
break;
}
case ModeQFont:
{
QFont font = mFont;
font.setFamily( family );
setCurrentFont( font );
QgsFontUtils::addRecentFontFamily( family );
break;
}
}
//.........这里部分代码省略.........
示例14: QTextEdit
QMultiLineEdit::QMultiLineEdit( QWidget *parent , const char *name )
: QTextEdit( parent, name )
{
d = new QMultiLineEditData;
setTextFormat( Qt::PlainText );
}
示例15: QTextEdit
TextEdit::TextEdit( QWidget *parent, const char *name )
: QTextEdit( parent, name )
{
setTextFormat( Qt::PlainText );
}