本文整理汇总了C++中QTextFrameFormat::setBackground方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextFrameFormat::setBackground方法的具体用法?C++ QTextFrameFormat::setBackground怎么用?C++ QTextFrameFormat::setBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextFrameFormat
的用法示例。
在下文中一共展示了QTextFrameFormat::setBackground方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendMessageToCurrentSession
/*! Append a new message to the current session and scroll to the end of the message protocol and
returns true if the action was successful. The \a messageColor defines the color of the message
box and should be provided as a full-color (no dimming required) color, as it is automatically
adjusted for the border and background.
*/
bool QwcPrivateMessager::appendMessageToCurrentSession(QTextDocument *document, const QString message, const QColor messageColor)
{
if (!document) { return false; }
QTextCursor cursor = document->rootFrame()->lastCursorPosition();
cursor.movePosition(QTextCursor::StartOfBlock);
QTextFrameFormat frameFormat;
frameFormat.setPadding(4);
frameFormat.setBackground(messageColor.lighter(190));
frameFormat.setMargin(0);
frameFormat.setBorder(2);
frameFormat.setBorderBrush(messageColor.lighter(150));
frameFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Outset);
// Title
QTextCharFormat backupCharFormat = cursor.charFormat();
QTextCharFormat newCharFormat;
newCharFormat.setFontPointSize(9);
QTextBlockFormat headerFormat;
headerFormat.setAlignment(Qt::AlignHCenter);
cursor.insertBlock(headerFormat);
cursor.setCharFormat(newCharFormat);
cursor.insertText(QDateTime::currentDateTime().toString());
QTextFrame *frame = cursor.insertFrame(frameFormat);
cursor.setCharFormat(backupCharFormat);
frame->firstCursorPosition().insertText(message);
return true;
}
示例2: reload_settings
void ServerWidget::reload_settings()
{
menu_quick_commands->clear();
for ( const auto& command : settings().quick_commands )
{
auto action = new QAction(command.first, this);
action->setData(command.second);
menu_quick_commands->addAction(action);
}
update_player_actions();
// Console
if ( settings().get("console/autocomplete", true) )
input_console->setWordCompleter(&complete_cvar);
else
input_console->setWordCompleter(nullptr);
input_console->setWordCompleterMinChars(settings().get("console/autocomplete/min_chars",1));
input_console->setWordCompleterMaxSuggestions(settings().get("console/autocomplete/max_suggestions",128));
input_console->setFont(settings().console_font);
/// \todo when it'll be a custom widget change accordingly
QTextFrameFormat fmt;
fmt.setBackground(settings().console_background);
output_console->document()->rootFrame()->setFrameFormat(fmt);
output_console->document()->setDefaultFont(settings().console_font);
output_console->setTextColor(settings().console_foreground);
}
示例3: clear
void XmlConsole::clear()
{
ui_.te->clear();
QTextFrameFormat f = ui_.te->document()->rootFrame()->frameFormat();
f.setBackground(QBrush(Qt::black));
ui_.te->document()->rootFrame()->setFrameFormat(f);
}
示例4: SIGNAL
//----------------------------------------------------------------------------
// XmlConsole
//----------------------------------------------------------------------------
XmlConsole::XmlConsole(PsiAccount *_pa)
:QWidget()
{
ui_.setupUi(this);
pa = _pa;
pa->dialogRegister(this);
connect(pa, SIGNAL(updatedAccount()), SLOT(updateCaption()));
connect(pa->client(), SIGNAL(xmlIncoming(const QString &)), SLOT(client_xmlIncoming(const QString &)));
connect(pa->client(), SIGNAL(xmlOutgoing(const QString &)), SLOT(client_xmlOutgoing(const QString &)));
connect(pa->psi(), SIGNAL(accountCountChanged()), this, SLOT(updateCaption()));
updateCaption();
prompt = 0;
ui_.te->setUndoRedoEnabled(false);
ui_.te->setReadOnly(true);
ui_.te->setAcceptRichText(false);
QTextFrameFormat f = ui_.te->document()->rootFrame()->frameFormat();
f.setBackground(QBrush(Qt::black));
ui_.te->document()->rootFrame()->setFrameFormat(f);
connect(ui_.pb_clear, SIGNAL(clicked()), SLOT(clear()));
connect(ui_.pb_input, SIGNAL(clicked()), SLOT(insertXml()));
connect(ui_.pb_close, SIGNAL(clicked()), SLOT(close()));
connect(ui_.pb_dumpRingbuf, SIGNAL(clicked()), SLOT(dumpRingbuf()));
connect(ui_.ck_enable, SIGNAL(clicked(bool)), ui_.gb_filter, SLOT(setEnabled(bool)));
resize(560,400);
}
示例5: fm
ClientTextEdit::ClientTextEdit(QWidget* parent) : QTextEdit(parent) {
setReadOnly(true);
setOverwriteMode(true);
setUndoRedoEnabled(false);
setDocumentTitle("mClient");
setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
setTabChangesFocus(false);
//_doc->setMaximumBlockCount(Config().scrollbackSize); // max number of lines?
document()->setUndoRedoEnabled(false);
QTextFrame* frame = document()->rootFrame();
_cursor = frame->firstCursorPosition();
// Default Colors
_foregroundColor = Qt::lightGray;
_backgroundColor = Qt::black;
_blackColor = Qt::darkGray;
_redColor = Qt::darkRed;
_greenColor = Qt::darkGreen;
_yellowColor = Qt::darkYellow;
_blueColor = Qt::darkBlue;
_magentaColor = Qt::darkMagenta;
_cyanColor = Qt::darkCyan;
_grayColor = Qt::lightGray;
_darkGrayColor = Qt::gray;
_brightRedColor = Qt::red;
_brightGreenColor = Qt::green;
_brightYellowColor = Qt::yellow;
_brightBlueColor = Qt::blue;
_brightMagentaColor = Qt::magenta;
_brightCyanColor = Qt::cyan;
_whiteColor = Qt::white;
// Default Fonts
_serverOutputFont = QFont("Monospace", 10);
_inputLineFont = QFont("Monospace", 10); //QApplication::font();
_serverOutputFont.setStyleHint(QFont::TypeWriter, QFont::PreferAntialias);
QTextFrameFormat frameFormat = frame->frameFormat();
frameFormat.setBackground(_backgroundColor);
frameFormat.setForeground(_foregroundColor);
frame->setFrameFormat(frameFormat);
_format = _cursor.charFormat();
setDefaultFormat(_format);
_defaultFormat = _format;
_cursor.setCharFormat(_format);
QFontMetrics fm(_serverOutputFont);
setTabStopWidth(fm.width(" ") * 8); // A tab is 8 spaces wide
QScrollBar* scrollbar = verticalScrollBar();
scrollbar->setSingleStep(fm.leading()+fm.height());
connect(scrollbar, SIGNAL(sliderReleased()),
this, SLOT(scrollBarReleased()));
previous = 0;
}
示例6: clear_log
void ServerWidget::clear_log()
{
output_console->clear();
/// \todo when it'll be a custom widget remove
QTextFrameFormat fmt;
fmt.setBackground(settings().console_background);
output_console->document()->rootFrame()->setFrameFormat(fmt);
output_console->document()->setDefaultFont(settings().console_font);
output_console->setTextColor(settings().console_foreground);
}
示例7: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// 获取文档对象
QTextDocument *document = ui->textEdit->document();
// 获取根框架
QTextFrame *rootFrame = document->rootFrame();
// 创建框架格式
QTextFrameFormat format;
// 边界颜色
format.setBorderBrush(Qt::red);
// 边界宽度
format.setBorder(3);
// 框架使用格式
rootFrame->setFrameFormat(format);
QTextFrameFormat frameFormat;
// 设置背景颜色
frameFormat.setBackground(Qt::lightGray);
// 设置边距
frameFormat.setMargin(10);
// 设置填衬
frameFormat.setPadding(5);
frameFormat.setBorder(2);
frameFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Dotted); //设置边框样式
// 获取光标
QTextCursor cursor = ui->textEdit->textCursor();
// 在光标处插入框架
cursor.insertFrame(frameFormat);
//以下是5.2.2节内容
QAction *action_textFrame = new QAction(tr("框架"),this);
connect(action_textFrame,SIGNAL(triggered()),this,SLOT(showTextFrame()));
// 在工具栏添加动作
ui->mainToolBar->addAction(action_textFrame);
QAction *action_textBlock = new QAction(tr("文本块"),this);
connect(action_textBlock,SIGNAL(triggered()),this,SLOT(showTextBlock()));
ui->mainToolBar->addAction(action_textBlock);
QAction *action_font = new QAction(tr("字体"),this);
// 设置动作可以被选中
action_font->setCheckable(true);
connect(action_font,SIGNAL(toggled(bool)),this,SLOT(setTextFont(bool)));
ui->mainToolBar->addAction(action_font);
}
示例8: HandlePrint
/* form qtexdocument to this margin an papersize */
void M_PageSize::HandlePrint( QTextDocument *doc )
{
const qreal RightMargin = P_margin.y();
const qreal LeftMargin = P_margin.height();
const qreal LargeDoc = G_regt.width() - RightMargin - LeftMargin;
doc->setPageSize ( G_regt.size() );
QTextFrame *Tframe = doc->rootFrame();
QTextFrameFormat Ftf = Tframe->frameFormat();
Ftf.setLeftMargin(P_margin.height());
Ftf.setBottomMargin(P_margin.width());
Ftf.setTopMargin(P_margin.x());
Ftf.setBackground(QBrush(Qt::transparent));
Ftf.setRightMargin(P_margin.y());
Ftf.setPadding ( 0);
Tframe->setFrameFormat(Ftf);
doc->setPageSize ( G_regt.size() );
}
示例9: SIGNAL
//----------------------------------------------------------------------------
// XmlConsole
//----------------------------------------------------------------------------
XmlConsole::XmlConsole(PsiAccount *_pa)
:QWidget()
{
#ifdef YAPSI
setStyle(YaStyle::defaultStyle());
#endif
ui_.setupUi(this);
pa = _pa;
pa->dialogRegister(this);
connect(pa, SIGNAL(updatedAccount()), SLOT(updateCaption()));
connect(pa->client(), SIGNAL(xmlIncoming(const QString &)), SLOT(client_xmlIncoming(const QString &)));
connect(pa->client(), SIGNAL(xmlOutgoing(const QString &)), SLOT(client_xmlOutgoing(const QString &)));
connect(pa->psi(), SIGNAL(accountCountChanged()), this, SLOT(updateCaption()));
updateCaption();
prompt = 0;
ui_.te->setUndoRedoEnabled(false);
ui_.te->setReadOnly(true);
ui_.te->setTextFormat(Qt::PlainText);
QTextFrameFormat f = ui_.te->document()->rootFrame()->frameFormat();
f.setBackground(QBrush(Qt::black));
ui_.te->document()->rootFrame()->setFrameFormat(f);
connect(ui_.pb_clear, SIGNAL(clicked()), SLOT(clear()));
connect(ui_.pb_input, SIGNAL(clicked()), SLOT(insertXml()));
connect(ui_.pb_close, SIGNAL(clicked()), SLOT(close()));
connect(ui_.pb_dumpRingbuf, SIGNAL(clicked()), SLOT(dumpRingbuf()));
connect(ui_.ck_enable, SIGNAL(clicked(bool)), ui_.gb_filter, SLOT(setEnabled(bool)));
#ifdef DEFAULT_XMLCONSOLE
enable();
#endif
#ifdef YAPSI
YaStyle::makeMeNativeLooking(this);
#endif
resize(560,400);
}
示例10: processSpecialNodes
QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes()
{
switch (currentNode->id) {
case Html_body:
if (currentNode->charFormat.background().style() != Qt::NoBrush) {
QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
fmt.setBackground(currentNode->charFormat.background());
doc->rootFrame()->setFrameFormat(fmt);
const_cast<QTextHtmlParserNode *>(currentNode)->charFormat.clearProperty(QTextFormat::BackgroundBrush);
}
break;
case Html_ol:
case Html_ul: {
QTextListFormat::Style style = currentNode->listStyle;
if (currentNode->id == Html_ul && !currentNode->hasOwnListStyle && currentNode->parent) {
const QTextHtmlParserNode *n = &at(currentNode->parent);
while (n) {
if (n->id == Html_ul) {
style = nextListStyle(currentNode->listStyle);
}
if (n->parent)
n = &at(n->parent);
else
n = 0;
}
}
QTextListFormat listFmt;
listFmt.setStyle(style);
++indent;
if (currentNode->hasCssListIndent)
listFmt.setIndent(currentNode->cssListIndent);
else
listFmt.setIndent(indent);
List l;
l.format = listFmt;
l.listNode = currentNodeIdx;
lists.append(l);
compressNextWhitespace = true;
// broken html: <ul>Text here<li>Foo
const QString simpl = currentNode->text.simplified();
if (simpl.isEmpty() || simpl.at(0).isSpace())
return ContinueWithNextNode;
break;
}
case Html_table: {
Table t = scanTable(currentNodeIdx);
tables.append(t);
hasBlock = false;
return ContinueWithNextNode;
}
case Html_tr:
return ContinueWithNextNode;
case Html_img: {
QTextImageFormat fmt;
fmt.setName(currentNode->imageName);
fmt.merge(currentNode->charFormat);
if (currentNode->imageWidth >= 0)
fmt.setWidth(currentNode->imageWidth);
if (currentNode->imageHeight >= 0)
fmt.setHeight(currentNode->imageHeight);
cursor.insertImage(fmt, QTextFrameFormat::Position(currentNode->cssFloat));
cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
cursor.mergeCharFormat(currentNode->charFormat);
cursor.movePosition(QTextCursor::Right);
hasBlock = false;
return ContinueWithNextNode;
}
case Html_hr: {
QTextBlockFormat blockFormat = currentNode->blockFormat;
blockFormat.setTopMargin(topMargin(currentNodeIdx));
blockFormat.setBottomMargin(bottomMargin(currentNodeIdx));
blockFormat.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, currentNode->width);
if (hasBlock && importMode == ImportToDocument)
cursor.mergeBlockFormat(blockFormat);
else
appendBlock(blockFormat);
hasBlock = false;
return ContinueWithNextNode;
}
default: break;
}
return ContinueWithCurrentNode;
}
示例11: palette
XmlConsole::XmlConsole(Client* client, QWidget *parent) :
QWidget(parent),
m_ui(new Ui::XmlConsole),
m_client(client), m_filter(0x1f)
{
m_ui->setupUi(this);
m_client->addXmlStreamHandler(this);
QPalette pal = palette();
pal.setColor(QPalette::Base, Qt::black);
pal.setColor(QPalette::Text, Qt::white);
m_ui->xmlBrowser->viewport()->setPalette(pal);
QTextDocument *doc = m_ui->xmlBrowser->document();
doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
doc->clear();
QTextFrameFormat format = doc->rootFrame()->frameFormat();
format.setBackground(QColor(Qt::black));
format.setMargin(0);
doc->rootFrame()->setFrameFormat(format);
QMenu *menu = new QMenu(m_ui->filterButton);
menu->setSeparatorsCollapsible(false);
menu->addSeparator()->setText(tr("Filter"));
QActionGroup *group = new QActionGroup(menu);
QAction *disabled = group->addAction(menu->addAction(tr("Disabled")));
disabled->setCheckable(true);
disabled->setData(Disabled);
QAction *jid = group->addAction(menu->addAction(tr("By JID")));
jid->setCheckable(true);
jid->setData(ByJid);
QAction *xmlns = group->addAction(menu->addAction(tr("By namespace uri")));
xmlns->setCheckable(true);
xmlns->setData(ByXmlns);
QAction *attrb = group->addAction(menu->addAction(tr("By all attributes")));
attrb->setCheckable(true);
attrb->setData(ByAllAttributes);
disabled->setChecked(true);
connect(group, SIGNAL(triggered(QAction*)), this, SLOT(onActionGroupTriggered(QAction*)));
menu->addSeparator()->setText(tr("Visible stanzas"));
group = new QActionGroup(menu);
group->setExclusive(false);
QAction *iq = group->addAction(menu->addAction(tr("Information query")));
iq->setCheckable(true);
iq->setData(XmlNode::Iq);
iq->setChecked(true);
QAction *message = group->addAction(menu->addAction(tr("Message")));
message->setCheckable(true);
message->setData(XmlNode::Message);
message->setChecked(true);
QAction *presence = group->addAction(menu->addAction(tr("Presence")));
presence->setCheckable(true);
presence->setData(XmlNode::Presence);
presence->setChecked(true);
QAction *custom = group->addAction(menu->addAction(tr("Custom")));
custom->setCheckable(true);
custom->setData(XmlNode::Custom);
custom->setChecked(true);
connect(group, SIGNAL(triggered(QAction*)), this, SLOT(onActionGroupTriggered(QAction*)));
m_ui->filterButton->setMenu(menu);
m_stackBracketsColor = QColor(0x666666);
m_stackIncoming.bodyColor = QColor(0xbb66bb);
m_stackIncoming.tagColor = QColor(0x006666);
m_stackIncoming.attributeColor = QColor(0x009933);
m_stackIncoming.paramColor = QColor(0xcc0000);
m_stackOutgoing.bodyColor = QColor(0x999999);
m_stackOutgoing.tagColor = QColor(0x22aa22);
m_stackOutgoing.attributeColor = QColor(0xffff33);
m_stackOutgoing.paramColor = QColor(0xdd8811);
QAction *action = new QAction(tr("Close"),this);
action->setSoftKeyRole(QAction::NegativeSoftKey);
connect(action, SIGNAL(triggered()), SLOT(close()));
addAction(action);
}