本文整理汇总了C++中QTextOption函数的典型用法代码示例。如果您正苦于以下问题:C++ QTextOption函数的具体用法?C++ QTextOption怎么用?C++ QTextOption使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QTextOption函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: width
void GraphicsWidget::drawControlText(QPainter &painter, int top,
const QString &labelText, const QString &valueText)
{
int labelLeft = width() - 200 + 5;
int labelWidth = 40;
int valueLeft = labelLeft + labelWidth + 10;
int valueWidth = 150;
if (!staticText.contains(labelText))
{
QStaticText t(labelText);
t.setPerformanceHint(QStaticText::AggressiveCaching);
t.setTextFormat(Qt::PlainText);
t.setTextWidth(labelWidth);
t.setTextOption(QTextOption(Qt::AlignRight));
staticText.insert(labelText, t);
}
if (!staticText.contains(valueText))
{
QStaticText t(valueText);
t.setPerformanceHint(QStaticText::AggressiveCaching);
t.setTextFormat(Qt::PlainText);
t.setTextWidth(valueWidth);
t.setTextOption(QTextOption(Qt::AlignLeft));
staticText.insert(valueText, t);
}
painter.drawStaticText(labelLeft, top, staticText.value(labelText));
painter.drawStaticText(valueLeft, top, staticText.value(valueText));
}
开发者ID:GHfangxin,项目名称:SearchVisualizer,代码行数:33,代码来源:graphicswidget.cpp
示例2: textRect
void GraphicsScene::drawForeground(QPainter *painter, const QRectF &rect)
{
QRectF textRect(rect.left(), rect.bottom()-100, rect.width(), 100);
painter->drawText(textRect, QString("copyright @ Wang Wei. SEU. Nanjing"), QTextOption(Qt::AlignCenter) );
QRectF titleRect(rect.left(), rect.top(), rect.width(), 50);
QFont titleFont;
titleFont.setPointSizeF(20);
titleFont.setWeight(QFont::Bold);
painter->setFont(titleFont);
painter->drawText(titleRect, QString(mTitle), QTextOption(Qt::AlignCenter));
}
开发者ID:duxiaodong,项目名称:graduate-pro,代码行数:12,代码来源:graphicsscene.cpp
示例3: QString
void QueueSystem::drawCountsRequests(QPainter *painter)
{
painter->save();
painter->setPen(getColorText());
painter->drawText(QRect(35, m_size.height() / 2, m_size.width() - 35, m_size.height() / 3),
QString(tr("Число элемнтов ")) + QString::number(m_countRequests),
QTextOption(Qt::AlignLeft));
painter->drawText(QRect(35, 3 * m_size.height() / 4, m_size.width() - 35, m_size.height() / 3),
QString(tr("Максимум ")) + QString::number(m_maxCountRequests),
QTextOption(Qt::AlignLeft));
painter->restore();
}
开发者ID:Vitek1425,项目名称:QueueingModel,代码行数:12,代码来源:queueSystem.cpp
示例4: painter
void IconButton::paintEvent(QPaintEvent *evt)
{
QPainter painter(this);
painter.drawPixmap(rect(),m_cur_icon);
if ( NULL == m_txt_lb )
painter.drawText(QRectF(rect()),m_txt,QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
}
开发者ID:xiaojianwu,项目名称:QtDeskTop,代码行数:7,代码来源:iconbutton.cpp
示例5: p
void OrientationWidget::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.setPen(palette().color(QPalette::Text));
p.setBrush(palette().window());
double radius = radiusCircle();
QPointF centerCircle = this->centerCircle();
p.drawEllipse(centerCircle, radius, radius);
p.translate(centerCircle);
p.rotate(_value);
p.drawLines(QVector<QLineF>()
<< QLineF(QPointF(-radius, 0), QPointF(radius, 0))
<< QLineF(QPointF(0, -radius), QPointF(0, radius)));
if(_value >= 90 && _value < 270) {
p.rotate(180);
p.drawText(QRectF(0.0, 0.0, radius-4, radius-4), tr("Droite"), QTextOption(Qt::AlignRight));
} else {
p.drawText(QPointF(-radius+4, -4), tr("Droite"));
}
}
开发者ID:rhadamants,项目名称:deling,代码行数:27,代码来源:OrientationWidget.cpp
示例6: p
void IntroPwdCheck::paintEvent(QPaintEvent *e) {
bool trivial = (rect() == e->rect());
QPainter p(this);
if (!trivial) {
p.setClipRect(e->rect());
}
if (trivial || e->rect().intersects(textRect)) {
p.setFont(st::introHeaderFont->f);
p.drawText(textRect, lang(lng_signin_title), style::al_top);
p.setFont(st::introFont->f);
p.drawText(textRect, lang(_pwdField.isHidden() ? lng_signin_recover_desc : lng_signin_desc), style::al_bottom);
}
if (_pwdField.isHidden()) {
if (!_emailPattern.isEmpty()) {
p.drawText(QRect(textRect.x(), _pwdField.y() + _pwdField.height() + st::introFinishSkip, textRect.width(), st::introFont->height), _emailPattern, style::al_top);
}
} else if (!_hint.isEmpty()) {
_hintText.drawElided(p, _pwdField.x(), _pwdField.y() + _pwdField.height() + st::introFinishSkip, _pwdField.width(), 1, style::al_top);
}
if (animating() || error.length()) {
p.setOpacity(errorAlpha.current());
QRect errRect((width() - st::introErrWidth) / 2, (_pwdField.y() + _pwdField.height() + st::introFinishSkip + st::introFont->height + _next.y() - st::introErrHeight) / 2, st::introErrWidth, st::introErrHeight);
p.setFont(st::introErrFont->f);
p.setPen(st::introErrColor->p);
p.drawText(errRect, error, QTextOption(style::al_center));
p.setOpacity(1);
}
}
开发者ID:0ps,项目名称:telegram,代码行数:31,代码来源:intropwdcheck.cpp
示例7: getLevel
void FilmstripFrames::drawFrameIcon(QPainter &p, const QRect &r, int index,
const TFrameId &fid, int flags) {
QPixmap pm;
TXshSimpleLevel *sl = getLevel();
if (sl) {
pm = IconGenerator::instance()->getIcon(sl, fid);
}
if (!pm.isNull()) {
p.drawPixmap(r.left(), r.top(), pm);
if (sl && sl->getType() == PLI_XSHLEVEL && flags & F_INBETWEEN_RANGE) {
int x1 = r.right();
int x0 = x1 - 12;
int y0 = r.top();
int y1 = r.bottom();
p.fillRect(x0, y0, x1 - x0 + 1, y1 - y0 + 1, QColor(180, 180, 180, 255));
p.setPen(Qt::black);
p.drawLine(x0 - 1, y0, x0 - 1, y1);
QPixmap inbetweenPixmap(
svgToPixmap(":Resources/filmstrip_inbetween.svg"));
p.drawPixmap(
x0 + 2,
y1 - inbetweenPixmap.height() / inbetweenPixmap.devicePixelRatio() -
3,
inbetweenPixmap);
}
} else {
// non riesco (per qualche ragione) a visualizzare l'icona
p.fillRect(r, QColor(255, 200, 200));
p.setPen(Qt::black);
p.drawText(r, tr("no icon"), QTextOption(Qt::AlignCenter));
}
}
开发者ID:jcome,项目名称:opentoonz,代码行数:34,代码来源:filmstrip.cpp
示例8: QWidget
FadingMultilineLabel::FadingMultilineLabel(QWidget* parent)
: QWidget(parent)
, textLayout_(0)
{
textOption_ = QTextOption(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);
textOption_.setWrapMode(QTextOption::WordWrap);
}
开发者ID:AlekSi,项目名称:Jabbin,代码行数:7,代码来源:fadingmultilinelabel.cpp
示例9: p
void FlatInput::paintEvent(QPaintEvent *e) {
Painter p(this);
p.fillRect(rect(), a_bgColor.current());
if (_st.borderWidth) {
QBrush b(a_borderColor.current());
p.fillRect(0, 0, width() - _st.borderWidth, _st.borderWidth, b);
p.fillRect(width() - _st.borderWidth, 0, _st.borderWidth, height() - _st.borderWidth, b);
p.fillRect(_st.borderWidth, height() - _st.borderWidth, width() - _st.borderWidth, _st.borderWidth, b);
p.fillRect(0, _st.borderWidth, _st.borderWidth, height() - _st.borderWidth, b);
}
if (_st.imgRect.pxWidth()) {
p.drawPixmap(_st.imgPos, App::sprite(), _st.imgRect);
}
bool phDraw = _phVisible;
if (animating()) {
p.setOpacity(a_phAlpha.current());
phDraw = true;
}
if (phDraw) {
p.save();
p.setClipRect(rect());
QRect phRect(placeholderRect());
phRect.moveLeft(phRect.left() + a_phLeft.current());
phPrepare(p);
p.drawText(phRect, _ph, QTextOption(_st.phAlign));
p.restore();
}
QLineEdit::paintEvent(e);
}
开发者ID:noscripter,项目名称:tdesktop,代码行数:30,代码来源:flatinput.cpp
示例10: QTextOption
void
SourceDelegate::paintCategory( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
painter->save();
QFont font = painter->font();
font.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
painter->setFont( font );
painter->setPen( Qt::black );
painter->setOpacity( 0.5 );
painter->drawText( option.rect.adjusted( m_margin / 2, 0, -m_margin, 0 ), index.data().toString().toUpper(), QTextOption( Qt::AlignVCenter ) );
if ( option.state & QStyle::State_MouseOver )
{
QString text = tr( "Show" );
if ( option.state & QStyle::State_Open )
text = tr( "Hide" );
// draw close icon
painter->setPen( TomahawkStyle::GROUP_HEADER );
painter->drawText( option.rect.translated( -m_margin / 4, 0 ), text, QTextOption( Qt::AlignVCenter | Qt::AlignRight ) );
}
painter->restore();
}
开发者ID:AshotN,项目名称:tomahawk,代码行数:26,代码来源:SourceDelegate.cpp
示例11: p
void EmojiBox::paintEvent(QPaintEvent *e) {
QPainter p(this);
if (_cache.isNull()) {
if (!_hiding || a_opacity.current() > 0.01) {
// fill bg
p.fillRect(0, 0, _width, _height, st::boxBG->b);
p.setFont(st::boxFont->f);
p.setPen(st::boxGrayTitle->p);
_header.draw(p, 0, st::boxPadding.top(), _width, Qt::AlignCenter);
p.setFont(st::emojiTextFont->f);
p.setPen(st::black->p);
int32 top = st::boxPadding.top() + st::boxFont->height + (st::emojiReplaceHeight - _blockHeight) / 2;
for (Blocks::const_iterator i = _blocks.cbegin(), e = _blocks.cend(); i != e; ++i) {
int32 rowSize = i->size(), left = (_width - rowSize * st::emojiReplaceWidth) / 2;
for (BlockRow::const_iterator j = i->cbegin(), en = i->cend(); j != en; ++j) {
if (j->emoji) {
QPoint pos(left + (st::emojiReplaceWidth - st::emojiSize) / 2, top + (st::emojiReplaceHeight - _blockHeight) / 2);
p.drawPixmap(pos, App::emojis(), QRect(j->emoji->x, j->emoji->y, st::emojiSize, st::emojiSize));
}
QRect trect(left, top + (st::emojiReplaceHeight + _blockHeight) / 2 - st::emojiTextFont->height, st::emojiReplaceWidth, st::emojiTextFont->height);
p.drawText(trect, j->text, QTextOption(Qt::AlignHCenter | Qt::AlignTop));
left += st::emojiReplaceWidth;
}
top += st::emojiReplaceHeight;
}
}
} else {
p.setOpacity(a_opacity.current());
p.drawPixmap(0, 0, _cache);
}
}
开发者ID:Freyja-Folkvangr,项目名称:tdesktop,代码行数:33,代码来源:emojibox.cpp
示例12: paintSection
void paintSection( QPainter * painter, const QRect& rect, int logicalIndex ) const override {
if ( rect.isValid() ) {
if ( logicalIndex > 0 ) {
QStyleOptionHeader op;
initStyleOption(&op);
op.text = "";
op.rect = rect;
op.textAlignment = Qt::AlignVCenter | Qt::AlignHCenter;
// draw the section
style()->drawControl( QStyle::CE_Header, &op, painter, this );
// html painting
painter->save();
QRect textRect = style()->subElementRect( QStyle::SE_HeaderLabel, &op, this );
painter->translate( textRect.topLeft() );
QTextDocument doc;
doc.setTextWidth( textRect.width() );
doc.setDefaultTextOption( QTextOption( Qt::AlignHCenter ) );
doc.setDocumentMargin(0);
doc.setHtml( model()->headerData( logicalIndex, Qt::Horizontal ).toString() );
doc.drawContents( painter, QRect( QPoint( 0, 0 ), textRect.size() ) );
painter->restore();
} else {
QHeaderView::paintSection( painter, rect, logicalIndex );
}
}
}
开发者ID:hermixy,项目名称:qtplatz,代码行数:27,代码来源:htmlheaderview.hpp
示例13: PremierPoint
/**
* Décrit le façon de dessiner l'élément sur la scène
*
* @brief Item_Tempo::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * option, QWidget * widget)
* @param pPainter le pinceau servant à dessiner sur la scène
* @param option Option sur le dessin (pas utile dans notre cas)
* @param widget Pointer vers le widget sur lequel l'item sera peint (pas utile dans notre cas)
* @see Item
*/
void Item_Tempo::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{
this->GererSelection(pPainter) ;
this->sTexte = this->pInstRepresentee->toString() ;
//Définition du dégradé
qreal top (this->rect.top()) ;
QPointF PremierPoint (0, top) ;
QPointF SecondPoint (0, -top) ;
QLinearGradient grad (PremierPoint, SecondPoint) ;
QColor PremiereCouleur (0x5E, 0xC1, 0xFF, 0xFF) ;
QColor SecondeCouleur (0x22, 0xAA, 0xFF, 0xFF) ;
grad.setColorAt(0, PremiereCouleur) ;
grad.setColorAt(1, SecondeCouleur) ;
//Définition du brush
QBrush brush(grad) ;
pPainter->setBrush(brush) ;
//Dessin de l'item
qreal Rayon (-top) ;
QPointF Centre (0, 0) ;
QRectF RectTexte (top, top, -2*top, -2*top) ;
pPainter->drawEllipse(Centre, Rayon, Rayon) ;
pPainter->setPen(QPen());
pPainter->drawText(RectTexte, sTexte, QTextOption(Qt::AlignCenter)) ;
}
开发者ID:lna44700,项目名称:openorganigram,代码行数:38,代码来源:Item_Tempo.cpp
示例14: QgsDebugMsg
void QgsMapCanvas::rendererJobFinished()
{
QgsDebugMsg( QString( "CANVAS finish! %1" ).arg( !mJobCancelled ) );
mMapUpdateTimer.stop();
// TODO: would be better to show the errors in message bar
Q_FOREACH ( const QgsMapRendererJob::Error& error, mJob->errors() )
{
QgsMessageLog::logMessage( error.layerID + " :: " + error.message, tr( "Rendering" ) );
}
if ( !mJobCancelled )
{
// take labeling results before emitting renderComplete, so labeling map tools
// connected to signal work with correct results
delete mLabelingResults;
mLabelingResults = mJob->takeLabelingResults();
QImage img = mJob->renderedImage();
// emit renderComplete to get our decorations drawn
QPainter p( &img );
emit renderComplete( &p );
QSettings settings;
if ( settings.value( "/Map/logCanvasRefreshEvent", false ).toBool() )
{
QString logMsg = tr( "Canvas refresh: %1 ms" ).arg( mJob->renderingTime() );
QgsMessageLog::logMessage( logMsg, tr( "Rendering" ) );
}
if ( mDrawRenderingStats )
{
int w = img.width(), h = img.height();
QFont fnt = p.font();
fnt.setBold( true );
p.setFont( fnt );
int lh = p.fontMetrics().height() * 2;
QRect r( 0, h - lh, w, lh );
p.setPen( Qt::NoPen );
p.setBrush( QColor( 0, 0, 0, 110 ) );
p.drawRect( r );
p.setPen( Qt::white );
QString msg = QString( "%1 :: %2 ms" ).arg( mUseParallelRendering ? "PARALLEL" : "SEQUENTIAL" ).arg( mJob->renderingTime() );
p.drawText( r, msg, QTextOption( Qt::AlignCenter ) );
}
p.end();
mMap->setContent( img, imageRect( img, mJob->mapSettings() ) );
}
// now we are in a slot called from mJob - do not delete it immediately
// so the class is still valid when the execution returns to the class
mJob->deleteLater();
mJob = 0;
emit mapCanvasRefreshed();
}
开发者ID:stevenmizuno,项目名称:QGIS,代码行数:60,代码来源:qgsmapcanvas.cpp
示例15: p
void FlatInput::paintEvent(QPaintEvent *e) {
QPainter p(this);
p.fillRect(rect(), a_bgColor.current());
if (_st.borderWidth) {
p.setPen(a_borderColor.current());
for (uint32 i = 0; i < _st.borderWidth; ++i) {
p.drawRect(i, i, width() - 2 * i - 1, height() - 2 * i - 1);
}
}
if (_st.imgRect.pxWidth()) {
p.drawPixmap(_st.imgPos, App::sprite(), _st.imgRect);
}
bool phDraw = _phVisible;
if (animating()) {
p.setOpacity(a_phAlpha.current());
phDraw = true;
}
if (phDraw) {
p.save();
p.setClipRect(rect());
QRect phRect(_st.textMrg.left() + _st.phPos.x() + a_phLeft.current(), _st.textMrg.top() + _st.phPos.y(), width() - _st.textMrg.left() - _st.textMrg.right(), height() - _st.textMrg.top() - _st.textMrg.bottom());
p.setFont(_st.font->f);
p.setPen(a_phColor.current());
p.drawText(phRect, _ph, QTextOption(_st.phAlign));
p.restore();
}
QLineEdit::paintEvent(e);
}
开发者ID:cesczuo,项目名称:tdesktop,代码行数:29,代码来源:flatinput.cpp
示例16: drawRotatedText
static void drawRotatedText (QPainter &p, int x, int y, int width, int height, float angle, const QString text) {
p.translate(x, y);
p.rotate(angle);
p.drawText(QRectF(0,0,width,height),text,QTextOption(Qt::AlignHCenter));
p.rotate(-1*angle);
p.translate(-1*x, -1*y);
}
开发者ID:infsega,项目名称:bbpref,代码行数:7,代码来源:scorewidget.cpp
示例17: p
void FlatTextarea::paintEvent(QPaintEvent *e) {
QPainter p(viewport());
QRect r(rect().intersected(e->rect()));
p.fillRect(r, _st.bgColor->b);
bool phDraw = _phVisible;
if (_a_appearance.animating()) {
p.setOpacity(a_phAlpha.current());
phDraw = true;
}
if (phDraw) {
p.save();
p.setClipRect(r);
p.setFont(_st.font);
p.setPen(a_phColor.current());
if (_st.phAlign == style::al_topleft && _phAfter > 0) {
p.drawText(_st.textMrg.left() - _fakeMargin + a_phLeft.current() + _st.font->width(getLastText().mid(0, _phAfter)), _st.textMrg.top() - _fakeMargin - st::lineWidth + _st.font->ascent, _ph);
} else {
QRect phRect(_st.textMrg.left() - _fakeMargin + _st.phPos.x() + a_phLeft.current(), _st.textMrg.top() - _fakeMargin + _st.phPos.y(), width() - _st.textMrg.left() - _st.textMrg.right(), height() - _st.textMrg.top() - _st.textMrg.bottom());
p.drawText(phRect, _ph, QTextOption(_st.phAlign));
}
p.restore();
p.setOpacity(1);
}
QTextEdit::paintEvent(e);
}
开发者ID:4ker,项目名称:tdesktop,代码行数:25,代码来源:flattextarea.cpp
示例18: handcard_num
ClientPlayer::ClientPlayer(Client *client)
:Player(client), handcard_num(0)
{
mark_doc = new QTextDocument(this);
mark_doc->setTextWidth(128);
mark_doc->setDefaultTextOption(QTextOption(Qt::AlignRight));
}
开发者ID:tgn3000,项目名称:QSanguosha,代码行数:7,代码来源:clientplayer.cpp
示例19: PremierPoint
/**
* Décrit le façon de dessiner l'élément sur la scène
*
* @brief Item_Ope::paint(QPainter *pPainter, const QStyleOptionGraphicsItem * option, QWidget * widget)
* @param pPainter le pinceau servant à dessiner sur la scène
* @param option Option sur le dessin (pas utile dans notre cas)
* @param widget Pointer vers le widget sur lequel l'item sera peint (pas utile dans notre cas)
* @see Item
*/
void Item_Ope::paint(QPainter *pPainter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
{
this->GererSelection(pPainter) ;
this->sTexte = this->pInstRepresentee->toString() ;
//Définition du dégradé dans l'item
qreal top (this->rect.top()) ;
QPointF PremierPoint (0, top) ;
QPointF SecondPoint (0, -top) ;
QLinearGradient grad (PremierPoint, SecondPoint) ;
QColor PremiereCouleur (0x98, 0xFE, 0x98, 0xFF) ;
QColor SecondeCouleur (0x62, 0xBA, 0x62, 0xFF) ;
grad.setColorAt(0, PremiereCouleur) ;
grad.setColorAt(1, SecondeCouleur) ;
//Définition du brush pour appliquer le dégradé
QBrush brush (grad) ;
//Dessin de l'item
pPainter->setBrush(brush);
pPainter->drawRect(rect);
pPainter->setPen(QPen());
pPainter->drawText(rect, sTexte, QTextOption(Qt::AlignCenter));
}
开发者ID:lna44700,项目名称:openorganigram,代码行数:34,代码来源:Item_Ope.cpp
示例20: name
void Board::drawStone(QPainter &p, int id)
{
if (isDead(id)) {
return;
}
QColor color;
if (red(id)) {
color = Qt::red;
}
else {
color = Qt::black;
}
p.setPen(QPen(QBrush(color), 2));
if (id == _selectid) {
p.setBrush(Qt::gray);
}
else {
p.setBrush(Qt::yellow);
}
p.drawEllipse(cell(id));
p.setFont(QFont("system", _r * 1.2, 700)); // 设置字体大小和类型
p.drawText(cell(id), name(id), QTextOption(Qt::AlignCenter));
}
开发者ID:yoferzhang,项目名称:Chess,代码行数:28,代码来源:Board.cpp
注:本文中的QTextOption函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论