您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ styled函数代码示例

51自学网 2021-06-03 08:32:58
  C++
这篇教程C++ styled函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中styled函数的典型用法代码示例。如果您正苦于以下问题:C++ styled函数的具体用法?C++ styled怎么用?C++ styled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了styled函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: createDoc

void Text::startEdit(MuseScoreView*, const QPointF& p)      {      _editMode = true;      if (styled()) {            createDoc();            setUnstyledText(SimpleText::getText());            layout();            }      _cursor = new QTextCursor(_doc);      _cursor->setVisualNavigation(true);      setCursor(p);      if (_cursor->position() == 0 && align()) {            QTextBlockFormat bf = _cursor->blockFormat();            Qt::Alignment alignment = 0;            if (align() & ALIGN_HCENTER)                  alignment |= Qt::AlignHCenter;            else if (align() & ALIGN_LEFT)                  alignment |= Qt::AlignLeft;            else if (align() & ALIGN_RIGHT)                  alignment |= Qt::AlignRight;            bf.setAlignment(alignment);            setBlockFormat(bf);            }      qreal w = 2.0; // 8.0 / view->matrix().m11();      score()->addRefresh(canvasBoundingRect().adjusted(-w, -w, w, w));      }
开发者ID:guifre2,项目名称:MuseScore,代码行数:27,


示例2: spatiumChanged

void Text::spatiumChanged(qreal oldVal, qreal newVal)      {      Element::spatiumChanged(oldVal, newVal);      if (!sizeIsSpatiumDependent() || styled())            return;      qreal v = newVal / oldVal;      QTextCursor c(_doc);      QTextBlock cb = _doc->begin();      while (cb.isValid()) {            QTextBlock::iterator i(cb.begin());            for (; !i.atEnd(); ++i) {                  QTextFragment f = i.fragment();                  if (f.isValid()) {                        int pos = f.position();                        int len = f.length();                        c.setPosition(pos, QTextCursor::MoveAnchor);                        c.setPosition(pos + len, QTextCursor::KeepAnchor);                        QTextCharFormat cf = c.charFormat();                        QFont font = cf.font();                        font.setPointSizeF(font.pointSizeF() * v);                        cf.setFont(font);                        c.setCharFormat(cf);                        }                  }            cb = cb.next();            }      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:29,


示例3: clear

void Text::clear()      {      if (styled())            SimpleText::clear();      else            _doc->clear();      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:7,


示例4: drawFrame

void Text::draw(QPainter* painter) const      {      drawFrame(painter);      if (styled()) {            SimpleText::draw(painter);            return;            }      QAbstractTextDocumentLayout::PaintContext c;      bool printing = score() && score()->printing();      if (_cursor         && _doc         && _cursor->document() == _doc         && !printing) {            if (_cursor->hasSelection()) {                  QAbstractTextDocumentLayout::Selection selection;                  selection.cursor = *_cursor;                  selection.format.setBackground(c.palette.brush(QPalette::Active, QPalette::Highlight));                  selection.format.setForeground(c.palette.brush(QPalette::Active, QPalette::HighlightedText));                  c.selections.append(selection);                  }            c.cursorPosition = _cursor->position();            }      else            c.cursorPosition = -1;      if ((printing || !score()->showInvisible()) && !visible())            return;      c.palette.setColor(QPalette::Text, textColor());      _doc->documentLayout()->draw(painter, c);      }
开发者ID:fivearrows,项目名称:MuseScore,代码行数:31,


示例5: getFragment

QTextDocumentFragment Text::getFragment() const      {      if (styled())            return QTextDocumentFragment::fromPlainText(getText());      else            return QTextDocumentFragment(_doc);      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:7,


示例6: textStyle

void Text::writeProperties(Xml& xml, bool writeText) const      {      Element::writeProperties(xml);      if (xml.clipboardmode || styled())            xml.tag("style", textStyle().name());      if (xml.clipboardmode || !styled())            _textStyle.writeProperties(xml);      if (writeText) {            if (styled())                  xml.tag("text", getText());            else {                  xml.stag("html-data");                  xml.writeHtml(_doc->toHtml("utf-8"));                  xml.etag();                  }            }      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:17,


示例7: setUnstyledText

void Text::setText(const QString& s)      {      if (styled())            SimpleText::setText(s);      else            setUnstyledText(s);      textChanged();      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:8,


示例8: styleChanged

void Text::styleChanged()      {      if (styled()) {            if (_styleIndex != TEXT_STYLE_UNKNOWN)                  setTextStyle(score()->textStyle(_styleIndex));            setText(getText());     // destroy formatting            score()->setLayoutAll(true);            }      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:9,


示例9: layout

void Text::layout()      {      if (styled() && !_editMode) {            SimpleText::layout();            }      else {            _doc->setDefaultFont(textStyle().font(spatium()));            qreal w = -1.0;            qreal x = 0.0;            qreal y = 0.0;            if (parent() && layoutToParentWidth()) {                  w = parent()->width();                  if (parent()->type() == HBOX || parent()->type() == VBOX || parent()->type() == TBOX) {                        Box* box = static_cast<Box*>(parent());                        x += box->leftMargin() * MScore::DPMM;                        y += box->topMargin() * MScore::DPMM;                        w = box->width()   - ((box->leftMargin() + box->rightMargin()) * MScore::DPMM);                        }                  }            QTextOption to = _doc->defaultTextOption();            to.setUseDesignMetrics(true);            to.setWrapMode(w <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);            _doc->setDefaultTextOption(to);            if (w < 0.0)                  w = _doc->idealWidth();            _doc->setTextWidth(w);            setbbox(QRectF(QPointF(0.0, 0.0), _doc->size()));            if (hasFrame())                  layoutFrame();            _doc->setModified(false);            textStyle().layout(this);      // process alignment#if 0 // TODO  TEXT_STYLE_TEXTLINE            if ((textStyle().align() & ALIGN_VCENTER) && (textStyle() == TEXT_STYLE_TEXTLINE)) {                  // special case: vertically centered text with TextLine needs to                  // take into account the line width                  TextLineSegment* tls = static_cast<TextLineSegment*>(parent());                  TextLine* tl = tls->textLine();                  if (tl) {                        qreal textlineLineWidth = point(tl->lineWidth());                        rypos() -= textlineLineWidth * .5;                        }                  }#endif            rxpos() += x;            rypos() += y;            }      if (parent() && parent()->type() == SEGMENT) {            Segment* s = static_cast<Segment*>(parent());            rypos() += s ? s->measure()->system()->staff(staffIdx())->y() : 0.0;            }      adjustReadPos();      }
开发者ID:guifre2,项目名称:MuseScore,代码行数:56,


示例10: endCursorEdit

void Text::endCursorEdit()      {      delete _cursor;      _cursor = 0;      if (styled()) {            SimpleText::setText(_doc->toPlainText());            delete _doc;            _doc = 0;            }      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:10,


示例11: moveCursor

void Text::moveCursor(int col)      {      if (styled()) {            SimpleText::moveCursor(col);            return;            }      if (_cursor)            _cursor->setPosition(col);      }
开发者ID:fivearrows,项目名称:MuseScore,代码行数:10,


示例12: moveCursorToEnd

void Text::moveCursorToEnd()      {      if (styled()) {            SimpleText::moveCursorToEnd();            return;            }      if (_cursor)            _cursor->movePosition(QTextCursor::End);      }
开发者ID:fivearrows,项目名称:MuseScore,代码行数:10,


示例13: endEdit

void Text::endEdit()      {      if (styled())            SimpleText::endEdit();      else {            _editMode = false;            endCursorEdit();            layoutEdit();            textChanged();            }      }
开发者ID:fivearrows,项目名称:MuseScore,代码行数:11,


示例14: baseLine

qreal Text::baseLine() const      {      if (styled())            return SimpleText::baseLine();      for (QTextBlock tb = _doc->begin(); tb.isValid(); tb = tb.next()) {            const QTextLayout* tl = tb.layout();            if (tl->lineCount())                  return (tl->lineAt(0).ascent() + tl->position().y());            }      return 0.0;      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:11,


示例15: createDoc

void Text::setUnstyled()      {      if (!styled())            return;      _styleIndex = TEXT_STYLE_UNSTYLED;      if (_editMode)            return;      createDoc();      if (!SimpleText::isEmpty())            setUnstyledText(SimpleText::getText());      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:11,


示例16: startEdit

void Text::startEdit(MuseScoreView* view, const QPointF& p)      {      if (styled()) {            SimpleText::startEdit(view, p);            return;            }      _cursor = new QTextCursor(_doc);      _cursor->setVisualNavigation(true);      setCursor(p);      qreal w = 2.0; // 8.0 / view->matrix().m11();      score()->rebuildBspTree();      score()->addRefresh(canvasBoundingRect().adjusted(-w, -w, w, w));      }
开发者ID:fivearrows,项目名称:MuseScore,代码行数:13,


示例17: qDebug

QTextCursor* Text::startCursorEdit()      {      if (styled()) {            qDebug("Text::startCursorEdit(): edit styled text/n");            return 0;            }      if (_cursor) {            qDebug("Text::startCursorEdit(): cursor already active/n");            return 0;            }      _cursor = new QTextCursor(_doc);      return _cursor;      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:13,


示例18: addChar

void Text::addChar(int code)      {      if (styled()) {            SimpleText::addChar(code);            return;            }      QString ss;      if (code & 0xffff0000) {            ss = QChar(QChar::highSurrogate(code));            ss += QChar(QChar::lowSurrogate(code));            }      else            ss = QChar(code);      _cursor->insertText(ss);      score()->setLayoutAll(true);      score()->end();      }
开发者ID:fivearrows,项目名称:MuseScore,代码行数:17,


示例19: shape

QPainterPath Text::shape() const      {      if (styled())            return SimpleText::shape();      QPainterPath pp;      for (QTextBlock tb = _doc->begin(); tb.isValid(); tb = tb.next()) {            QTextLayout* tl = tb.layout();            int n = tl->lineCount();            for (int i = 0; i < n; ++i) {                  QTextLine l = tl->lineAt(i);                  QRectF r(l.naturalTextRect().translated(tl->position()));                  r.adjust(-l.position().x(), 0.0, 0.0, 0.0);                  pp.addRect(r);                  }            }      return pp;      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:18,


示例20: setCursor

bool Text::setCursor(const QPointF& p, QTextCursor::MoveMode mode)      {      if (styled())            return SimpleText::setCursor(p, mode);      QPointF pt  = p - canvasPos();      if (!bbox().contains(pt))            return false;      int idx = _doc->documentLayout()->hitTest(pt, Qt::FuzzyHit);      if (idx == -1)            return true;      if (_cursor) {            _cursor->setPosition(idx, mode);            if (_cursor->hasSelection())                  QApplication::clipboard()->setText(_cursor->selectedText(), QClipboard::Selection);            }      return true;      }
开发者ID:fivearrows,项目名称:MuseScore,代码行数:18,


示例21: drawFrame

void Text::draw(QPainter* painter) const      {      drawFrame(painter);      if (styled() && !_editMode) {            SimpleText::draw(painter);            return;            }      QAbstractTextDocumentLayout::PaintContext c;      bool printing = score() && score()->printing();      if (_cursor         && _doc         && _cursor->document() == _doc         && !printing) {            if (_cursor->hasSelection()) {                  QAbstractTextDocumentLayout::Selection selection;                  selection.cursor = *_cursor;                  selection.format.setBackground(c.palette.brush(QPalette::Active, QPalette::Highlight));                  selection.format.setForeground(c.palette.brush(QPalette::Active, QPalette::HighlightedText));                  c.selections.append(selection);                  }            c.cursorPosition = _cursor->position();            }      else            c.cursorPosition = -1;      if ((printing || !score()->showInvisible()) && !visible())            return;      c.palette.setColor(QPalette::Text, textColor());#if 1      // make it thread save      {      QWriteLocker locker(&docRenderLock);      QScopedPointer<QTextDocument> __doc(_doc->clone());      __doc.data()->documentLayout()->draw(painter, c);      // _doc->documentLayout()->draw(painter, c);      }#else      _doc->documentLayout()->draw(painter, c);#endif      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:41,


示例22: qDebug

void Text::spatiumChanged(qreal oldVal, qreal newVal)      {      Element::spatiumChanged(oldVal, newVal);#if 0qDebug("Text::spatiumChanged %d  -- %s %s %p %f/n",      sizeIsSpatiumDependent(), name(), parent() ? parent()->name() : "?", this, newVal);#endif      if (!sizeIsSpatiumDependent() || styled())            return;      qreal v = newVal / oldVal;      QTextCursor c(_doc);      c.movePosition(QTextCursor::Start);      for (;;) {            c.select(QTextCursor::BlockUnderCursor);            QTextCharFormat cf = c.charFormat();            QFont font = cf.font();            font.setPointSizeF(font.pointSizeF() * v);            cf.setFont(font);            c.setCharFormat(cf);            if (!c.movePosition(QTextCursor::NextBlock))                  break;            }      }
开发者ID:guifre2,项目名称:MuseScore,代码行数:23,


示例23: layout

void FiguredBass::layout()      {      if (!styled())            setTextStyle(TEXT_STYLE_FIGURED_BASS);      Lyrics::layout();      qreal lh = lineSpacing() * score()->styleD(ST_figuredBassLineHeight);      System* sys = measure()->system();      if (sys == 0) {            qDebug("lyrics layout: no system!");            abort();            }      const QList<Lyrics*>* ll = &(chordRest()->lyricsList());      int line = ll->indexOf(this);      qreal y  = lh * line + point(score()->styleS(ST_figuredBassDistance))                 + sys->staff(staffIdx())->bbox().height();      QString s = getText();      qreal x = symbols[score()->symIdx()][quartheadSym].width(magS()) * .5;      QFontMetricsF fm(style().font(spatium()));      for (int i = 0; i < s.size(); ++i) {            if (s[i].isNumber()) {                  if (i)                        x += -fm.width(s.left(i));                  int startIdx = i;                  for (; i < s.size(); ++i) {                        if (!s[i].isNumber())                              break;                        }                  x += -(fm.width(s.mid(startIdx, i - startIdx)) * .5);                  break;                  }            }      x -= spatium() * .25;  // DEBUG      setPos(x, y);      }
开发者ID:Mistobaan,项目名称:MuseScore,代码行数:36,


示例24: addSymbol

void Text::addSymbol(const SymCode& s)      {      if (styled()) {            SimpleText::addSymbol(s);            return;            }      if (s.fontId >= 0) {            QTextCharFormat nFormat(_cursor->charFormat());            nFormat.setFontFamily(fontId2font(s.fontId).family());            QString ss;            if (s.code >= 0x10000) {                  ss = QChar(QChar::highSurrogate(s.code));                  ss += QChar(QChar::lowSurrogate(s.code));                  }            else                  ss = QChar(s.code);            _cursor->insertText(ss, nFormat);            }      else            _cursor->insertText(QChar(s.code));      score()->setLayoutAll(true);      score()->end();      }
开发者ID:fivearrows,项目名称:MuseScore,代码行数:24,


示例25: styled

QString Text::getHtml() const      {      return styled() ? "" : _doc->toHtml("utf-8");      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:4,


示例26: setModified

void Text::setModified(bool v)      {      if (!styled())            _doc->setModified(v);      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:5,


示例27: return

QString Text::getText() const      {      return (styled() && !_editMode) ? SimpleText::getText() : _doc->toPlainText();      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:4,


示例28: o

void Text::layout1()      {      if (styled() && !_editMode)            SimpleText::layout();      else {            _doc->setDefaultFont(textStyle().font(spatium()));            qreal w = -1.0;            QPointF o(textStyle().offset(spatium()));            if (parent() && layoutToParentWidth()) {                  Element* e = parent();                  w = e->width();                  if (e->type() == HBOX || e->type() == VBOX || e->type() == TBOX) {                        Box* b = static_cast<Box*>(e);                        w -= ((b->leftMargin() + b->rightMargin()) * MScore::DPMM);                        }                  }            QTextOption to = _doc->defaultTextOption();            to.setUseDesignMetrics(true);            to.setWrapMode(w <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);            _doc->setDefaultTextOption(to);            if (w <= 0.0)                  w = _doc->idealWidth();            _doc->setTextWidth(w);            QSizeF size(_doc->size());            if (align() & ALIGN_BOTTOM)                  o.ry() -= size.height();            else if (align() & ALIGN_VCENTER)                  o.ry() -= (size.height() * .5);            else if (align() & ALIGN_BASELINE)                  o.ry() -= baseLine();            if (align() & ALIGN_RIGHT)                  o.rx() -= size.width();            else if (align() & ALIGN_HCENTER)                  o.rx() -= (size.width() * .5);            setbbox(QRectF(QPointF(0.0, 0.0), size));            _doc->setModified(false);            setPos(o);            }      if (parent()) {            Element* e = parent();            qreal w, h, xo, yo;            if (layoutToParentWidth()) {                  if (e->type() == HBOX || e->type() == VBOX || e->type() == TBOX) {                        // consider inner margins of frame                        Box* b = static_cast<Box*>(e);                        xo = b->leftMargin() * MScore::DPMM;                        yo = b->topMargin()  * MScore::DPMM;                        w  = b->width()  - xo - b->rightMargin() * MScore::DPMM;                        h  = b->height() - yo - b->bottomMargin()   * MScore::DPMM;                        }                  else {                        w  = e->width();                        h  = e->height();                        xo = 0.0;                        yo = 0.0;                        }                  QPointF ro(_textStyle.reloff() * .01);                  rxpos() += xo + ro.x() * w;                  rypos() += yo + ro.y() * h;                  }            if (e->type() == SEGMENT) {                  Segment* s = static_cast<Segment*>(e);                  rypos() += s->measure()->system()->staff(staffIdx())->y();                  }            }      if (hasFrame())            layoutFrame();      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:76,



注:本文中的styled函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ sub函数代码示例
C++ styleSheet函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。