本文整理汇总了C++中QTextFrameFormat类的典型用法代码示例。如果您正苦于以下问题:C++ QTextFrameFormat类的具体用法?C++ QTextFrameFormat怎么用?C++ QTextFrameFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTextFrameFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: document
void ChatEdit::updateMargins()
{
QTextFrameFormat frameFormat = document()->rootFrame()->frameFormat();
frameFormat.setLeftMargin(10);
frameFormat.setRightMargin(10);
document()->rootFrame()->setFrameFormat(frameFormat);
}
示例3: writeFrameFormat
void QTextOdfWriter::writeFrameFormat(QXmlStreamWriter &writer, QTextFrameFormat format, int formatIndex) const
{
writer.writeStartElement(styleNS, QString::fromLatin1("style"));
writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("s%1").arg(formatIndex));
writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("section"));
writer.writeEmptyElement(styleNS, QString::fromLatin1("section-properties"));
if (format.hasProperty(QTextFormat::FrameTopMargin))
writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) );
if (format.hasProperty(QTextFormat::FrameBottomMargin))
writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) );
if (format.hasProperty(QTextFormat::FrameLeftMargin))
writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.), format.leftMargin())) );
if (format.hasProperty(QTextFormat::FrameRightMargin))
writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) );
writer.writeEndElement(); // style
// TODO consider putting the following properties in a qt-namespace.
// Position position () const
// qreal border () const
// QBrush borderBrush () const
// BorderStyle borderStyle () const
// qreal padding () const
// QTextLength width () const
// QTextLength height () const
// PageBreakFlags pageBreakPolicy () const
}
示例4: QAction
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);
}
示例5: connect
//----------------------------------------------------------------------------
// 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);
}
示例6: text_writer
text_writer( docEdit& e ) : edit( e ) {
QTextCursor cursor = edit.textCursor();
cursor.movePosition( QTextCursor::Start );
mainFrame = cursor.currentFrame();
plainFormat = cursor.charFormat();
plainFormat.setFontPointSize( 10 );
paragraphFormat = plainFormat;
paragraphFormat.setFontPointSize( 12 );
headingFormat = plainFormat;
headingFormat.setFontWeight( QFont::Bold );
headingFormat.setFontPointSize( 16 );
empasisFormat = plainFormat;
empasisFormat.setFontItalic( true );
tagFormat = plainFormat;
tagFormat.setForeground( QColor( "#990000" ) );
tagFormat.setFontUnderline( true );
underlineFormat = plainFormat;
underlineFormat.setFontUnderline( true );
frameFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Inset );
frameFormat.setBorder( 1 );
frameFormat.setMargin( 10 );
frameFormat.setPadding( 4 );
}
示例7: QGraphicsItem
TextLayer::TextLayer(const int layer_id , QGraphicsItem *parent , QGraphicsScene *scene )
: QGraphicsItem(parent,scene),evesum(0),modus(Show),border(1.),currentprintrender(false),
hi(Metric("30px")),wi(Metric("110px")),bgcolor(QColor(Qt::white)),SwapLockBreak(false),
bordercolor(QColor(Qt::red)),Rotate(0),check_view_area_time(0),ActionHover(false),
format(DIV_ABSOLUTE),mount(new TextController)
{
mount->q = this;
setAcceptsHoverEvents(true);
wisub_border = wi + border;
history.clear();
id = layer_id;
setAcceptDrops(true);
setFlag(QGraphicsItem::ItemIsSelectable,true);
setFlag(QGraphicsItem::ItemIsFocusable,true);
setFlag(QGraphicsItem::ItemIsMovable,false);
setSelected(false);
_doc = new QTextDocument();
_doc->setHtml(tr("<p>Write your text<p>"));
QTextFrame *Tframe = _doc->rootFrame();
QTextFrameFormat rootformats = Tframe->frameFormat();
rootformats.setWidth(wi);
rootformats.setBorder(0);
Tframe->setFrameFormat(rootformats);
_doc->setPageSize(QSizeF(wi,hi));
DLayout = _doc->documentLayout();
setDocument(_doc);
mount->txtControl()->document()->toHtml().size(); /* connect all */
setZValue(1.99999);
RestoreMoveAction();
init();
}
示例8: DefaultFrameFormat
QTextFrameFormat DefaultFrameFormat()
{
QTextFrameFormat base;
base.setBorderBrush ( Qt::blue );
base.setBorderStyle ( QTextFrameFormat::BorderStyle_Solid );
base.setBorder ( 0.6 );
return base;
}
示例9:
QTextFrame *QTextDocumentPrivate::rootFrame() const
{
if (!rtFrame) {
QTextFrameFormat defaultRootFrameFormat;
defaultRootFrameFormat.setMargin(DefaultRootFrameMargin);
rtFrame = qobject_cast<QTextFrame *>(const_cast<QTextDocumentPrivate *>(this)->createObject(defaultRootFrameFormat));
}
return rtFrame;
}
示例10: QTextEdit
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;
}
示例11: setChapterCounter
/*!
* \author Anders Fernström
* \date 2006-03-02
*
* \brief set the chapter counter
*/
void InputCell::setChapterCounter( QString number )
{
chaptercounter_->selectAll();
chaptercounter_->setPlainText( number );
chaptercounter_->setAlignment( (Qt::AlignmentFlag)Qt::AlignRight );
QTextFrameFormat format = chaptercounter_->document()->rootFrame()->frameFormat();
format.setMargin( style_.textFrameFormat()->margin() +
style_.textFrameFormat()->border() +
style_.textFrameFormat()->padding() );
chaptercounter_->document()->rootFrame()->setFrameFormat( format );
}
示例12: 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);
}
示例13: emitTable
void HtmlExporter::emitFrame( QTextFrame::Iterator frameIt )
{
// kDebug() << "html" << html;
if ( !frameIt.atEnd() ) {
QTextFrame::Iterator next = frameIt;
++next;
if ( next.atEnd()
&& frameIt.currentFrame() == 0
&& frameIt.parentFrame() != doc->rootFrame()
&& frameIt.currentBlock().begin().atEnd() ) {
return;
}
}
for ( QTextFrame::Iterator it = frameIt;
!it.atEnd(); ++it ) {;
if ( QTextFrame *f = it.currentFrame() ) {
// qDebug() << "Its a frame, not a block" << endl;
if ( QTextTable * table = qobject_cast<QTextTable *>( f ) ) {
emitTable( table );
} else {
// qDebug() << "isn't table" << endl;
html += QLatin1String( "\n<table" );
QTextFrameFormat format = f->frameFormat();
if ( format.hasProperty( QTextFormat::FrameBorder ) ) {
emitAttribute( "border", QString::number( format.border() ) );
}
html += QLatin1String( " style=\"-qt-table-type: frame;" );
emitFloatStyle( format.position(), OmitStyleTag );
if ( format.hasProperty( QTextFormat::FrameMargin ) ) {
const QString margin = QString::number( format.margin() );
emitMargins( margin, margin, margin, margin );
}
html += QLatin1Char( '\"' );
emitTextLength( "width", format.width() );
emitTextLength( "height", format.height() );
QBrush bg = format.background();
if ( bg != Qt::NoBrush ) {
emitAttribute( "bgcolor", bg.color().name() );
}
html += QLatin1Char( '>' );
html += QLatin1String( "\n<tr>\n<td style=\"border: none;\">" );
emitFrame( f->begin() );
html += QLatin1String( "</td></tr></table>" );
}
} else if ( it.currentBlock().isValid() ) {
// qDebug()<< "is valid" << endl;
emitBlock( it.currentBlock() );
}
}
}
示例14: c
void KDReports::TextDocumentData::updatePercentSizes( const QSizeF& size )
{
QTextCursor c( m_document );
c.beginEditBlock();
// TODO only if we inserted resizable images
do {
c.movePosition( QTextCursor::NextCharacter );
QTextCharFormat format = c.charFormat();
if ( format.hasProperty( ResizableImageProperty ) ) {
Q_ASSERT( format.isImageFormat() );
QTextImageFormat imageFormat = format.toImageFormat();
updatePercentSize( imageFormat, size );
//qDebug() << "updatePercentSizes: setting image to " << imageFormat.width() << "," << imageFormat.height();
c.movePosition( QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor );
c.setCharFormat( imageFormat );
c.movePosition( QTextCursor::NextCharacter );
}
} while ( !c.atEnd() );
if (m_usesTabPositions) {
QTextFrameFormat rootFrameFormat = m_document->rootFrame()->frameFormat();
const int rootFrameMargins = rootFrameFormat.leftMargin() + rootFrameFormat.rightMargin();
QTextBlock block = m_document->firstBlock();
do {
QTextBlockFormat blockFormat = block.blockFormat();
QList<QTextOption::Tab> tabs = blockFormat.tabPositions();
//qDebug() << "Looking at block" << block.blockNumber() << "tabs:" << tabs.count();
if (!tabs.isEmpty()) {
for (int i = 0; i < tabs.count(); ++i) {
QTextOption::Tab& tab = tabs[i];
if ( tab.delimiter == QLatin1Char('P') /* means Page -- see rightAlignedTab*/) {
if ( tab.type == QTextOption::RightTab ) {
//qDebug() << "Adjusted RightTab from" << tab.position << "to" << size.width();
tab.position = size.width() - rootFrameMargins;
} else if ( tab.type == QTextOption::CenterTab ) {
tab.position = ( size.width() - rootFrameMargins ) / 2;
}
}
}
blockFormat.setTabPositions( tabs );
//qDebug() << "Adjusted tabs:" << tabs;
c.setPosition( block.position() );
c.setBlockFormat( blockFormat );
}
block = block.next();
} while ( block.isValid() );
}
c.endEditBlock();
}
示例15: unapplyStyle
void KoSectionStyle::unapplyStyle(QTextFrame §ion) const
{
if (d->parentStyle)
d->parentStyle->unapplyStyle(section);
QTextFrameFormat format = section.frameFormat();
QList<int> keys = d->stylesPrivate.keys();
for (int i = 0; i < keys.count(); i++) {
QVariant variant = d->stylesPrivate.value(keys[i]);
if (variant == format.property(keys[i]))
format.clearProperty(keys[i]);
}
section.setFrameFormat(format);
}