当前位置: 首页>>代码示例>>C++>>正文


C++ QTextEdit::font方法代码示例

本文整理汇总了C++中QTextEdit::font方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::font方法的具体用法?C++ QTextEdit::font怎么用?C++ QTextEdit::font使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTextEdit的用法示例。


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

示例1: 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();
}
开发者ID:KanagiMiss,项目名称:testassist,代码行数:26,代码来源:mainwindow.cpp

示例2: on_noteTextEditCodeResetButton_clicked

/**
 * Resets the font for the note text code edit
 */
void SettingsDialog::on_noteTextEditCodeResetButton_clicked()
{
    QTextEdit textEdit;
    noteTextEditCodeFont = textEdit.font();
    noteTextEditCodeFont.setFamily("Courier");
    setFontLabel(ui->noteTextEditCodeFontLabel, noteTextEditCodeFont);
}
开发者ID:LiangWei88,项目名称:QOwnNotes,代码行数:10,代码来源:settingsdialog.cpp

示例3: insertQuestionTypeTitle

void MainWindow::insertQuestionTypeTitle(const QString &title)
{
    QTextEdit *pEdit = textEditor.editor;
    QTextCursor cursor = pEdit->textCursor();

    cursor.insertText(tr("\n"));
    pEdit->setTextCursor(cursor);

    cursor.insertText(title+" ");
    pEdit->setTextCursor(cursor);

    //set font of title and info
    QFont font = pEdit->font();
    QTextCharFormat fmt;
    font.setBold(true);
    font.setPointSize(13);
    fmt.setFont(font);
    cursor.select(QTextCursor::BlockUnderCursor);
    cursor.mergeCharFormat(fmt);

    cursor.select(QTextCursor::WordUnderCursor);
    cursor.insertText("\n");
    pEdit->setTextCursor(cursor);

    //set font of questions
    cursor.insertText(" ");
    font.setBold(false);
    font.setPointSize(10);
    fmt.setFont(font);
    cursor.select(QTextCursor::BlockUnderCursor);
    cursor.mergeCharFormat(fmt);

    cursor.select(QTextCursor::WordUnderCursor);
    cursor.deletePreviousChar();
    pEdit->setTextCursor(cursor);
}
开发者ID:KanagiMiss,项目名称:testassist,代码行数:36,代码来源:mainwindow.cpp

示例4: 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);
//.........这里部分代码省略.........
开发者ID:DundalkIT,项目名称:pcp,代码行数:101,代码来源:pmquery.cpp

示例5: formatQuestions

void MainWindow::formatQuestions(const PACKEDQUESTIONS &qset)
{

    TestAssistance *pt = TestAssistance::get();
    QTextEdit *pEdit = textEditor.editor;
    QTextCursor cursor = pEdit->textCursor();

    //set alignment center
    pEdit->setAlignment(Qt::AlignHCenter);
    groupCheck(0);

    //set font of title and info
    QFont font = pEdit->font();
    QTextCharFormat fmt;
    font.setBold(true);
    font.setPointSize(14);
    fmt.setFont(font);
    cursor.select(QTextCursor::BlockUnderCursor);
    cursor.mergeCharFormat(fmt);

    //insert school name
    cursor.insertText(tr("%1\n").arg(pt->getPaperInfo().strSchool));

    //insert title
    cursor.insertText(tr("“%1”专业(学院) 2011—2012学年第一学期\n").arg(pt->getPaperInfo().major));


    //insert paper info
    cursor.insertText(tr("《%1》期末考试试卷(%2卷) 考核形式(%3卷)\n").arg(pt->getPaperInfo().strCourse)
                      .arg(pt->getPaperInfo().strPaperType).arg(((pt->getPaperInfo().bOpenOrClose)?"开":"闭")));

    //insert author
    cursor.insertText(tr("作者:%1\n").arg(pt->getPaperInfo().strAuthor));

    pEdit->setTextCursor(cursor);

    //set alignment left
    pEdit->setAlignment(Qt::AlignLeft);
    groupCheck(2);

    //get judge
    QString text;
    int type = 0;

    const std::vector<QUESTION> &j = qset.judge;
    if(!j.empty()){
        insertQuestionTypeTitle(tr("%1.判断题").arg(digitToChinese(type+1)));
        type++;

        for(size_t i = 0; i != j.size(); ++i){
            cursor.insertText(tr("%1.").arg(i+1) + j[i].txt + "\n");
            if(!j[i].imgBytes.isEmpty()){
                QImage img;
                img.loadFromData(j[i].imgBytes, "PNG");
                cursor.insertImage(img);
                cursor.insertText("\n\n");
            }
            pEdit->setTextCursor(cursor);
        }
    }

    //get choice
    text.clear();
    const std::vector<QUESTION> &c = qset.choice;
    if(!c.empty()){
        insertQuestionTypeTitle(tr("%1.选择题").arg(digitToChinese(type+1)));
        type++;

        for(size_t i = 0; i != c.size(); ++i){
            cursor.insertText(tr("%1.").arg(i+1) + c[i].txt + "\n");
            if(!c[i].imgBytes.isEmpty()){
                QImage img;
                img.loadFromData(c[i].imgBytes, "PNG");
                cursor.insertImage(img);
                cursor.insertText("\n\n");
            }
            else
                cursor.insertText("\n");
            pEdit->setTextCursor(cursor);
        }
    }

    //get fill
    text.clear();
    const std::vector<QUESTION> &f = qset.fill;
    if(!f.empty()){
        insertQuestionTypeTitle(tr("%1.填空题").arg(digitToChinese(type+1)));
        type++;

        for(size_t i = 0; i != f.size(); ++i){
            cursor.insertText(tr("%1.").arg(i+1) + f[i].txt + "\n");
            if(!f[i].imgBytes.isEmpty()){
                QImage img;
                img.loadFromData(f[i].imgBytes, "PNG");
                cursor.insertImage(img);
                cursor.insertText("\n\n");
            }
            pEdit->setTextCursor(cursor);
        }
    }
//.........这里部分代码省略.........
开发者ID:KanagiMiss,项目名称:testassist,代码行数:101,代码来源:mainwindow.cpp

示例6: on_noteTextEditResetButton_clicked

/**
 * Resets the font for the note text edit
 */
void SettingsDialog::on_noteTextEditResetButton_clicked()
{
    QTextEdit textEdit;
    noteTextEditFont = textEdit.font();
    setFontLabel(ui->noteTextEditFontLabel, noteTextEditFont);
}
开发者ID:LiangWei88,项目名称:QOwnNotes,代码行数:9,代码来源:settingsdialog.cpp


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