本文整理汇总了C++中QTextEdit::currentFont方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::currentFont方法的具体用法?C++ QTextEdit::currentFont怎么用?C++ QTextEdit::currentFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::currentFont方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: currentFont
QFont QTextEditProto::currentFont() const
{
QTextEdit *item = qscriptvalue_cast<QTextEdit*>(thisObject());
if (item)
return item->currentFont();
return QFont();
}
示例2: currentFont
int TextEdit::currentFont(lua_State * L) // const : QFont
{
QTextEdit* obj = ObjectHelper<QTextEdit>::check( L, 1);
QFont* res = ValueInstaller2<QFont>::create( L );
*res = obj->currentFont();
return 1;
}/*
示例3: createLogPage
QTextEdit* VBoxVMLogViewer::createLogPage (const QString &aName)
{
QWidget *pageContainer = new QWidget();
QVBoxLayout *pageLayout = new QVBoxLayout (pageContainer);
QTextEdit *logViewer = new QTextEdit (pageContainer);
pageLayout->addWidget (logViewer);
pageLayout->setContentsMargins (10, 10, 10, 10);
QFont font = logViewer->currentFont();
font.setFamily ("Courier New,courier");
logViewer->setFont (font);
logViewer->setWordWrapMode (QTextOption::NoWrap);
logViewer->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
logViewer->setReadOnly (true);
mLogList->addTab (pageContainer, aName);
return logViewer;
}
示例4: fontMetrics
GeneralSetup::GeneralSetup(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
connect(ui.acceptButton, SIGNAL(clicked()),
this, SLOT(acceptButtonClicked()));
setWindowIcon(QIcon(":/icons/Mesh3D.png"));
// Set minimum height for free text editors:
QTextEdit *te = ui.headerFreeTextEdit;
QFont currentFont = te->currentFont();
QFontMetrics fontMetrics(currentFont);
int fontHeight = fontMetrics.height();
ui.headerFreeTextEdit->setMinimumHeight(3*fontHeight);
ui.simulationFreeTextEdit->setMinimumHeight(3*fontHeight);
ui.constantsFreeTextEdit->setMinimumHeight(3*fontHeight);
}
示例5: setModel
void SqlItemView::setModel(QAbstractItemModel * model)
{
m_model = model;
QSqlQueryModel * t = qobject_cast<QSqlQueryModel *>(model);
if (!t) { return; }
QSqlRecord rec(t->record());
if (scrollWidget->widget())
{
delete scrollWidget->takeWidget();
}
QWidget * layoutWidget = new QWidget(scrollWidget);
m_gridLayout = new QGridLayout(layoutWidget);
QString tmp("%1:");
for (int i = 0; i < rec.count(); ++i)
{
m_gridLayout->addWidget(
new QLabel(tmp.arg(rec.fieldName(i)), layoutWidget), i, 0);
QTextEdit * w = new QTextEdit(layoutWidget);
w->setReadOnly(false);
w->setAcceptRichText(false);
int mh = QFontMetrics(w->currentFont()).lineSpacing();
w->setMinimumHeight(mh);
w->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::MinimumExpanding);
m_gridLayout->addWidget(w, i, 1);
m_gridLayout->setRowMinimumHeight(i, mh);
connect(w, SIGNAL(textChanged()),
this, SLOT(textChanged()));
}
scrollWidget->setWidget(layoutWidget);
m_count = rec.count();
}
示例6: execute
/*!
* \class TextCursorChangeFontFace
* \author Anders Fernström
* \date 2005-11-03
* \date 2006-01-13 (update)
*
* \brief Command for changing font face
*
* 2005-11-07 AF, Added function (case 4) in switch to change
* strikckout settings
* 2005-11-15 AF, added trick to get correct style on links
* 2006-01-13 AF, remove trick to get correct style on links because
* it made undo/redo work incorrectly
*/
void TextCursorChangeFontFace::execute()
{
QTextEdit *editor = document()->getCursor()->currentCell()->textEdit();
QFont font;
if( editor )
{
switch( face_ )
{
case 0: // Plain
editor->setFontWeight( QFont::Normal );
editor->setFontItalic( false );
editor->setFontUnderline( false );
font = editor->currentFont();
font.setStrikeOut( false );
editor->setCurrentFont( font );
break;
case 1: // Bold
if( editor->fontWeight() != QFont::Normal )
editor->setFontWeight( QFont::Normal );
else
editor->setFontWeight( QFont::Bold );
break;
case 2: // Italic
if( editor->fontItalic() )
editor->setFontItalic( false );
else
editor->setFontItalic( true );
break;
case 3: // Underline
if( editor->fontUnderline() )
editor->setFontUnderline( false );
else
editor->setFontUnderline( true );
break;
case 4: // Strickout
font = editor->currentFont();
if( font.strikeOut() )
font.setStrikeOut( false );
else
font.setStrikeOut( true );
editor->setCurrentFont( font );
break;
}
// ugly trick to make the sure that the links haven't change
// color
/*
if( !editor->toPlainText().isEmpty() )
{
int start = editor->textCursor().selectionStart();
int end = editor->textCursor().selectionEnd();
editor->setHtml( editor->toHtml() );
QTextCursor cursor( editor->textCursor() );
cursor.setPosition( start );
cursor.setPosition( end, QTextCursor::KeepAnchor );
editor->setTextCursor( cursor );
}*/
}
}
示例7: setupTabs
//----------------------------------------------------------------------------
void DynamicEditor::setupTabs(QDomDocument *elmerDefs, const QString &Section, int ID)
{
// Clear:
//-------
this->ID = ID;
hash.clear();
QLayout *layout = this->layout();
if(layout != NULL) {
QLayoutItem *item;
while((item = layout->takeAt(0)) != 0)
delete item;
if(tabWidget != NULL) {
tabWidget->clear();
delete tabWidget;
}
delete layout;
}
// Get root element of elmerDefs:
//-------------------------------
root = elmerDefs->documentElement();
tabWidget = new QTabWidget;
//tabWidget->setTabShape(QTabWidget::Triangular);
tabWidget->setUsesScrollButtons(true);
tabWidget->setElideMode(Qt::ElideNone);
all_stuff = root.firstChildElement("ALL");
element = root.firstChildElement("PDE");
tabs = 0;
while(!element.isNull()) {
name = element.firstChildElement("Name");
QGridLayout *grid = new QGridLayout;
int params = 0;
for( int iter=0; iter<2; iter++ )
{
if ( iter==0 ) {
if ( name.text().trimmed() == "General" ) continue;
section = all_stuff.firstChildElement(Section);
} else {
section = element.firstChildElement(Section);
}
param = section.firstChildElement("Parameter");
// ML: Added argument "Parameter" for nextSiblingElement(), 5. August 2010:
for( ; !param.isNull(); param=param.nextSiblingElement("Parameter"), params++ ) {
// label
QString widget_type = param.attribute("Widget","Edit");
QString widget_enabled = param.attribute("Enabled","True");
QString widget_visible = param.attribute("Visible","True");
QString paramType = param.firstChildElement("Type").text().trimmed();
QString labelName = param.firstChildElement("Name").text().trimmed();
QString sifName = param.firstChildElement("SifName").text().trimmed();
if ( sifName == "" ) sifName = labelName;
QString paramDefault = param.firstChildElement("DefaultValue").text().trimmed();
QString whatis = param.firstChildElement("Whatis").text().trimmed();
QString statusTip = param.firstChildElement("StatusTip").text().trimmed();
QString fullName = "/"+name.text().trimmed()+"/"+Section+"/"+labelName+"/"+QString::number(ID);
h.widget = NULL;
if ( widget_type == "Edit" ) {
DynLineEdit *edit = new DynLineEdit;
h.widget = edit->lineEdit;
edit->lineEdit->setText(paramDefault);
edit->name = fullName;
connect(edit->lineEdit, SIGNAL(returnPressed()),
edit, SLOT(editSlot()));
connect(edit->lineEdit, SIGNAL(textChanged(QString)),
this, SLOT(textChangedSlot(QString)));
} else if (widget_type == "TextEdit") {
QTextEdit *textEdit = new QTextEdit;
// set height to 5..8 lines of current font:
QFont currentFont = textEdit->currentFont();
QFontMetrics fontMetrics(currentFont);
int fontHeight = fontMetrics.height();
textEdit->setMinimumHeight(5*fontHeight);
textEdit->setMaximumHeight(8*fontHeight);
h.widget = textEdit;
} else if ( widget_type == "Combo" ) {
QComboBox *combo = new QComboBox;
h.widget = combo;
// combo->setObjectName(labelName); // removed 30. sept. 2008, ML
int count = 0, active=0;
QDomElement item = param.firstChildElement("Item");
for( ; !item.isNull(); item=item.nextSiblingElement("Item") ) {
QString itemType = item.attribute( "Type", "" );
//.........这里部分代码省略.........