本文整理汇总了C++中QTextEdit::setFont方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::setFont方法的具体用法?C++ QTextEdit::setFont怎么用?C++ QTextEdit::setFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::setFont方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createLicensePanel
QWidget* AboutBox::createLicensePanel()
{
// Create a label to display readme.txt
QTextEdit* label = new QTextEdit();
label->setReadOnly(true);
QString fileName(QString::fromUtf8(m_gleInterface->getManualLocation().c_str()));
fileName.resize(fileName.lastIndexOf(QDir::separator()));
fileName += QDir::separator();
fileName += tr("LICENSE.txt");
GLEInterface* iface = GLEGetInterfacePointer();
std::string licenseFileTxt;
bool res = iface->readFileOrGZIPTxt(fileName.toUtf8().constData(), &licenseFileTxt);
if (res) {
QFont font;
// Set the font to be fixed pitch
font.setFixedPitch(true);
font.setFamily("Courier");
font.setStretch(QFont::Condensed);
label->setLineWrapMode(QTextEdit::NoWrap);
label->setFont(font);
label->setTextColor(Qt::black);
// Get the text and put it in the label
label->setPlainText(licenseFileTxt.c_str());
QFontMetrics fm(font);
m_minWidth = fm.width("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
} else {
label->setPlainText(tr("File not found: '%1'").arg(fileName));
}
return label;
}
示例2: typeWriterFontChanged
void ConsoleImpl::typeWriterFontChanged() {
QTextEdit* te = textEditOutput;
te->setFont(QGit::TYPE_WRITER_FONT);
te->setPlainText(te->toPlainText());
te->moveCursor(QTextCursor::End);
}
示例3: on_insertTitle_clicked
void MainWindow::on_insertTitle_clicked()
{
QTextEdit *pEdit = textEditor.editor;
QTextCursor cursor = pEdit->textCursor();
//set alignment center
pEdit->setAlignment(Qt::AlignHCenter);
groupCheck(0);
//insert title
cursor.insertText("“ ”学院 2011—2012学年第一学期\n");
//insert paper info
cursor.insertText("《 》期末考试试卷( 卷) 考核形式( 卷)\n");
//set alignment left
pEdit->setAlignment(Qt::AlignLeft);
groupCheck(2);
QFont font = pEdit->font();
font.setBold(true);
font.setPointSize(16);
pEdit->setFont(font);
pEdit->setTextCursor(cursor);
pEdit->setFocus();
}
示例4: qDebug
ZoomConfigurator::ZoomConfigurator(QWidget *parent) :QWidget(parent)
{
#ifdef K_DEBUG
#ifdef Q_OS_WIN32
qDebug() << "[ZoomConfigurator()]";
#else
TINIT;
#endif
#endif
QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom);
scale = new QLabel(tr("Scale Factor"));
scale->setFont(QFont("Arial", 8, QFont::Normal, false));
scale->setAlignment(Qt::AlignHCenter);
layout->addWidget(scale);
factor = new QDoubleSpinBox();
factor->setDecimals(1);
factor->setSingleStep(0.1);
factor->setMinimum(0.1);
factor->setMaximum(0.9);
layout->addWidget(factor);
QLabel *label = new QLabel(tr("Tips"));
label->setAlignment(Qt::AlignHCenter);
label->setFont(QFont("Arial", 8, QFont::Normal, false));
QTextEdit *textArea = new QTextEdit;
textArea->setFont(QFont("Arial", 8, QFont::Normal, false));
textArea->setHtml("<p><b>" + tr("Zoom Square mode") + ":</b> " + tr("Press Ctrl key + Mouse left button") + "</p>");
QString text = textArea->document()->toPlainText();
int height = (text.length()*270)/207;
textArea->setFixedHeight(height);
mainLayout->addLayout(layout);
mainLayout->addWidget(label);
mainLayout->addWidget(textArea);
mainLayout->addStretch(2);
TCONFIG->beginGroup("ZoomTool");
double value = TCONFIG->value("zoomFactor", -1).toDouble();
if (value > 0)
factor->setValue(value);
else
factor->setValue(0.5);
}
示例5: 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;
}
示例6: createAngularCodeTab
void Window::createAngularCodeTab()
{
// Create angular code widget
angularCode = new QWidget;
// Sets the layout for the angular code
angularCode->setLayout(configCodecAreaWidgets());
// Do the configuration of the font for the angular code text box
QFont font;
font.setFamily("Chines & Internacional");
font.setCapitalization(QFont::AllLowercase);
font.setPointSize(28);
// Recovers the text box for the angular code widget
QTextEdit *currentTextBox = angularCode->findChild<QTextEdit *>();
// Sets the font for the text box
currentTextBox->setFont(font);
}
示例7: licenseFile
LicenseDialog::LicenseDialog(QWidget *parent) :
QDialog(parent)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle("License");
QVBoxLayout* layout = new QVBoxLayout(this);
QTextEdit* licenseEdit = new QTextEdit(this);
licenseEdit->setReadOnly(true);
QFile licenseFile(":/license");
licenseFile.open(QIODevice::ReadOnly | QIODevice::Text);
licenseEdit->setText(licenseFile.readAll());
QFont font("Monospace");
font.setStyleHint(QFont::TypeWriter);
licenseEdit->setFont(font);
layout->addWidget(licenseEdit);
setMinimumSize(600, 500);
}
示例8: if
PmQuery::PmQuery(bool inputflag, bool printflag, bool noframeflag,
bool nosliderflag, bool usesliderflag, bool exclusiveflag)
: QDialog()
{
QHBoxLayout *hboxLayout;
QVBoxLayout *vboxLayout;
QSpacerItem *spacerItem;
QSpacerItem *spacerItem1;
QVBoxLayout *vboxLayout1;
QHBoxLayout *hboxLayout1;
QSpacerItem *spacerItem2;
QString filename;
if (iconic == HOST_ICON)
filename = tr(":images/dialog-host.png");
else if (iconic == ERROR_ICON)
filename = tr(":images/dialog-error.png");
else if (iconic == WARNING_ICON)
filename = tr(":images/dialog-warning.png");
else if (iconic == ARCHIVE_ICON)
filename = tr(":images/dialog-archive.png");
else if (iconic == QUESTION_ICON)
filename = tr(":images/dialog-question.png");
else // (iconic == INFO_ICON)
filename = tr(":images/dialog-information.png");
QIcon icon(filename);
QPixmap pixmap(filename);
setWindowIcon(icon);
setWindowTitle(tr(title));
QGridLayout *gridLayout = new QGridLayout(this);
gridLayout->setSpacing(6);
gridLayout->setMargin(9);
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setMargin(0);
vboxLayout = new QVBoxLayout();
vboxLayout->setSpacing(6);
vboxLayout->setMargin(0);
spacerItem = new QSpacerItem(20, 2, QSizePolicy::Minimum,
QSizePolicy::Expanding);
vboxLayout->addItem(spacerItem);
QLabel *imageLabel = new QLabel(this);
imageLabel->setPixmap(pixmap);
vboxLayout->addWidget(imageLabel);
spacerItem1 = new QSpacerItem(20, 20, QSizePolicy::Minimum,
QSizePolicy::Expanding);
vboxLayout->addItem(spacerItem1);
hboxLayout->addLayout(vboxLayout);
vboxLayout1 = new QVBoxLayout();
vboxLayout1->setSpacing(6);
vboxLayout1->setMargin(0);
int height;
int width = DEFAULT_EDIT_WIDTH;
QLineEdit* lineEdit = NULL;
QTextEdit* textEdit = NULL;
if (inputflag && messagecount <= 1) {
lineEdit = new QLineEdit(this);
if (messagecount == 1)
lineEdit->setText(tr(messages[0]));
height = lineEdit->font().pointSize() + 4;
if (height < 0)
height = lineEdit->font().pixelSize() + 4;
if (height < 0)
height = lineEdit->heightForWidth(width) + 4;
lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::Fixed);
lineEdit->setMinimumSize(QSize(width, height));
lineEdit->setGeometry(QRect(0, 0, width, height));
vboxLayout1->addWidget(lineEdit);
}
else {
QFont fixed("monospace");
fixed.setStyleHint(QFont::TypeWriter);
textEdit = new QTextEdit(this);
textEdit->setFont(fixed);
textEdit->setLineWrapMode(QTextEdit::FixedColumnWidth);
textEdit->setLineWrapColumnOrWidth(80);
textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
if (nosliderflag)
textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
else if (usesliderflag)
textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
else
textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
for (int m = 0; m < messagecount; m++)
textEdit->append(tr(messages[m]));
if (inputflag)
textEdit->setReadOnly(false);
else {
textEdit->setLineWidth(1);
//.........这里部分代码省略.........