void EditorRichText::setDefaultFont(QFont font) { // Some default fonts on Windows have a default size of 7.8, // which results in complicated rich text generated by toHtml(). // Use an integer value. const int pointSize = qRound(font.pointSizeF()); if (pointSize > 0 && !qFuzzyCompare(qreal(pointSize), font.pointSizeF())) font.setPointSize(pointSize); document()->setDefaultFont(font); if (font.pointSize() > 0) setFontPointSize(font.pointSize()); else setFontPointSize(QFontInfo(font).pointSize()); emit textChanged(); }
CMyTextBrowser::CMyTextBrowser(QTextBrowser *parent) : QTextBrowser(parent) { /*! * \brief 功能概述 构造函数 * \param 参数描述 * \return 返回值描述 * \author zzy * \date 2015/1/16 */ this->document()->setMaximumBlockCount(1000); pMenu = new QMenu("右键菜单",this); pStopAction = new QAction("暂停刷新",0); pStopAction->setIcon(QIcon(":/images/close.png")); pStopAction->setStatusTip("暂停刷新报文"); pStartAction = new QAction("开始刷新",0); pStartAction->setIcon(QIcon(":/images/savesyn.png")); pStartAction->setStatusTip("开始刷新报文"); pClearAction = new QAction("清空所有",0); pClearAction->setIcon(QIcon(":/images/delete.png")); pClearAction->setStatusTip("清空所有报文"); pSaveFrame = new QAction("保存报文",0); // pSaveFrame->setIconText(QIcon("")); pSaveFrame->setStatusTip("保存此通道的报文"); pSaveFrame->setCheckable(true); m_pSignFrame = new QAction("标记报文",0); m_pSignFrame->setStatusTip("标记特殊报文"); pMenu->addAction(pStopAction); pMenu->addAction(pStartAction); pMenu->addAction(pClearAction); pMenu->addAction(pSaveFrame); pMenu->addAction(m_pSignFrame); connect(pStopAction,SIGNAL(triggered()),this,SLOT(OnStopRefresh())); connect(pStartAction,SIGNAL(triggered()),this,SLOT(OnStartRefresh())); connect(pClearAction,SIGNAL(triggered()),this,SLOT(OnClearAll())); connect(pSaveFrame,SIGNAL(triggered(bool)),this,SLOT(OnSaveFrame(bool))); connect(m_pSignFrame,SIGNAL(triggered()),this,SLOT(OnSignFrame())); //初始状态 //pStopAction->setDisabled(1); pStartAction->setDisabled(1); pClearAction->setDisabled(1); bPauseFlag = false; // 当 true 时,显示背景颜色 // 当 false 时,字体带颜色 m_bTextColor = false; // nClearCounter = 0; m_bSaveMsgFlag = true; m_bSaveFrame = false; setFontPointSize(11);///设置显示字体的大小 }
void keyPressEvent(QKeyEvent* event) { switch(event->key()) { case Qt::Key_PageUp: case Qt::Key_Plus: event->accept(); if(getFontPointSize() < 48) setFontPointSize(getFontPointSize() + 1); QWidget::update(); break; case Qt::Key_PageDown: case Qt::Key_Minus: event->accept(); if(getFontPointSize() > 3) setFontPointSize(getFontPointSize() - 1); QWidget::update(); break; default: QWidget::keyPressEvent(event); break; } }
CABSLBehaviorWidget(CABSLBehaviorView& cabslBehaviorView, QWidget* parent) : QWidget(parent), cabslBehaviorView(cabslBehaviorView) { setFocusPolicy(Qt::StrongFocus); setBackgroundRole(QPalette::Base); font = QApplication::font(); boldFont = font; boldFont.setBold(true); setFontPointSize(getFontPointSize()); const QPalette& pal(QApplication::palette()); altBrush = pal.alternateBase(); fontPen.setColor(pal.text().color()); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); }
DisplayWidget::DisplayWidget(QWidget *parent) : QTextEdit(parent) { setReadOnly(true); setTabChangesFocus(true); setOverwriteMode(true); setAlignment(Qt::AlignCenter); resetLine(); append(tr("Welcome to the Free Group Calculator!\n")); setAlignment(Qt::AlignLeft); setFontFamily("Monaco"); setFontPointSize(12.0); append(tr("[%1 %2]:>").arg(Input).arg(lineNumber)); moveCursor(QTextCursor::End); }
TeamComm3DWidget(TeamComm3DView& view, QHeaderView* headerView, QWidget* parent) : QWidget(parent), view(view), headerView(headerView), baseBrush(QPalette().base()), noPen(Qt::NoPen) { setFocusPolicy(Qt::StrongFocus); setBackgroundRole(QPalette::Base); font = QApplication::font(); boldFont = font; boldFont.setBold(true); setFontPointSize(getFontPointSize()); const QPalette& pal(QApplication::palette()); altBrush = pal.alternateBase(); fontPen.setColor(pal.text().color()); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QSettings& settings = TeamComm3DCtrl::application->getLayoutSettings(); settings.beginGroup(view.fullName); headerView->restoreState(settings.value("HeaderState").toByteArray()); settings.endGroup(); }
void KNoteEdit::setTextFontSize( int size ) { setFontPointSize( size ); }
HtmlEditor::HtmlEditor(HtmlContent *htmlContent, QWidget *parent) : NoteEditor(htmlContent), m_htmlContent(htmlContent) { FocusedTextEdit *textEdit = new FocusedTextEdit(/*disableUpdatesOnKeyPress=*/true,parent); textEdit->setLineWidth(0); textEdit->setMidLineWidth(0); textEdit->setFrameStyle(QFrame::Box); textEdit->setAutoFormatting(Settings::autoBullet() ? QTextEdit::AutoAll : QTextEdit::AutoNone); QPalette palette; palette.setColor(textEdit->backgroundRole(), note()->backgroundColor()); palette.setColor(textEdit->foregroundRole(), note()->textColor()); textEdit->setPalette(palette); textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); textEdit->setHtml(Tools::tagCrossReferences(m_htmlContent->html(), /*userLink=*/true)); textEdit->moveCursor(QTextCursor::End); textEdit->verticalScrollBar()->setCursor(Qt::ArrowCursor); setInlineEditor(textEdit); connect(textEdit, SIGNAL(mouseEntered()), this, SIGNAL(mouseEnteredEditorWidget())); connect(textEdit, SIGNAL(escapePressed()), this, SIGNAL(askValidation())); connect(InlineEditors::instance()->richTextFont, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(onFontSelectionChanged(const QFont&))); connect(InlineEditors::instance()->richTextFontSize, SIGNAL(sizeChanged(qreal)), textEdit, SLOT(setFontPointSize(qreal))); connect(InlineEditors::instance()->richTextColor, SIGNAL(activated(const QColor&)), textEdit, SLOT(setTextColor(const QColor&))); connect(InlineEditors::instance()->focusWidgetFilter, SIGNAL(escapePressed()), textEdit, SLOT(setFocus())); connect(InlineEditors::instance()->focusWidgetFilter, SIGNAL(returnPressed()), textEdit, SLOT(setFocus())); connect(InlineEditors::instance()->richTextFont, SIGNAL(activated(int)), textEdit, SLOT(setFocus())); connect(InlineEditors::instance()->richTextFontSize, SIGNAL(activated(int)), textEdit, SLOT(setFocus())); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat&)), this, SLOT(charFormatChanged(const QTextCharFormat&))); // connect( textEdit, SIGNAL(currentVerticalAlignmentChanged(VerticalAlignment)), this, SLOT(slotVerticalAlignmentChanged()) ); connect(InlineEditors::instance()->richTextBold, SIGNAL(triggered(bool)), this, SLOT(setBold(bool))); connect(InlineEditors::instance()->richTextItalic, SIGNAL(triggered(bool)), textEdit, SLOT(setFontItalic(bool))); connect(InlineEditors::instance()->richTextUnderline, SIGNAL(triggered(bool)), textEdit, SLOT(setFontUnderline(bool))); connect(InlineEditors::instance()->richTextLeft, SIGNAL(triggered()), this, SLOT(setLeft())); connect(InlineEditors::instance()->richTextCenter, SIGNAL(triggered()), this, SLOT(setCentered())); connect(InlineEditors::instance()->richTextRight, SIGNAL(triggered()), this, SLOT(setRight())); connect(InlineEditors::instance()->richTextJustified, SIGNAL(triggered()), this, SLOT(setBlock())); // InlineEditors::instance()->richTextToolBar()->show(); cursorPositionChanged(); charFormatChanged(textEdit->currentCharFormat()); //QTimer::singleShot( 0, this, SLOT(cursorPositionChanged()) ); InlineEditors::instance()->enableRichTextToolBar(); connect(InlineEditors::instance()->richTextUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); connect(InlineEditors::instance()->richTextRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); connect(textEdit, SIGNAL(undoAvailable(bool)), InlineEditors::instance()->richTextUndo, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(redoAvailable(bool)), InlineEditors::instance()->richTextRedo, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(textChanged()), this, SLOT(editTextChanged())); InlineEditors::instance()->richTextUndo->setEnabled(false); InlineEditors::instance()->richTextRedo->setEnabled(false); connect(textEdit, SIGNAL(cursorPositionChanged()), htmlContent->note()->basket(), SLOT(editorCursorPositionChanged())); // In case it is a very big note, the top is displayed and Enter is pressed: the cursor is on bottom, we should enure it visible: QTimer::singleShot(0, htmlContent->note()->basket(), SLOT(editorCursorPositionChanged())); }
void CHTMLWriteDisplay::changeFontSize(int newSize) { setFontPointSize((qreal)newSize); }