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


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

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


在下文中一共展示了QTextEdit::setAlignment方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QFont font("ZYSong18030",12);
    a.setFont(font);
    //主分割窗口
    QSplitter *splitterMain =new QSplitter(Qt::Horizontal,0);
    QTextEdit *textLeft =new QTextEdit(QObject::tr("Left Widget"),splitterMain);
    textLeft->setAlignment(Qt::AlignCenter);
    //右部分割窗口
    QSplitter *splitterRight =new QSplitter(Qt::Vertical,splitterMain);
    splitterRight->setOpaqueResize(false);
    QTextEdit *textUp =new QTextEdit(QObject::tr("Top Widget"),splitterRight);
    textUp->setAlignment(Qt::AlignCenter);
    QTextEdit *textBottom =new QTextEdit(QObject::tr("Bottom Widget"),splitterRight);
    textBottom->setAlignment(Qt::AlignCenter);
    splitterMain->setStretchFactor(1,1);
    splitterMain->setWindowTitle(QObject::tr("Splitter"));
    splitterMain->show();

    //MainWindow w;
    //w.show();
    
    return a.exec();
}
开发者ID:Pengfei-Gao,项目名称:develop-reference-data,代码行数:25,代码来源:main.cpp

示例3: onTextAlignTriggerred

void MailEditorMainWindow::onTextAlignTriggerred(QAction *a)
  {
  QTextEdit* edit = ui->messageEdit;
  if (a == ui->actionLeft)
    edit->setAlignment(Qt::AlignLeft | Qt::AlignAbsolute);
  else if (a == ui->actionCenter)
    edit->setAlignment(Qt::AlignHCenter);
  else if (a == ui->actionRight)
    edit->setAlignment(Qt::AlignRight | Qt::AlignAbsolute);
  else if (a == ui->actionJustify)
    edit->setAlignment(Qt::AlignJustify);

  alignmentChanged(edit->alignment());
  }
开发者ID:toby82,项目名称:keyhotee,代码行数:14,代码来源:maileditorwindow.cpp

示例4: execute

  /*!
     * \class TextCursorChangeTextAlignment
   * \author Anders Fernström
   * \date 2005-11-03
   * \date 2005-11-07 (update)
     *
     * \brief Command for changing text alignment
   *
   * 2005-11-07 AF, implemented the function
     */
  void TextCursorChangeTextAlignment::execute()
  {
    QTextEdit *editor = document()->getCursor()->currentCell()->textEdit();

    if( editor )
    {
      editor->setAlignment( (Qt::Alignment)alignment_ );

      // create a rule for the alignment
      Rule *rule;
      if( (Qt::Alignment)alignment_ == Qt::AlignLeft )
        rule = new Rule( "TextAlignment", "Left" );
      else if( (Qt::Alignment)alignment_ == Qt::AlignRight )
        rule = new Rule( "TextAlignment", "Right" );
      else if( (Qt::Alignment)alignment_ == Qt::AlignHCenter )
        rule = new Rule( "TextAlignment", "Center" );
      else if( (Qt::Alignment)alignment_ == Qt::AlignJustify )
        rule = new Rule( "TextAlignment", "Justify" );
      else
        rule = new Rule( "TextAlignment", "Left" );

      document()->getCursor()->currentCell()->addRule( rule );

      // update the cells style
      document()->getCursor()->currentCell()->style()->setAlignment( alignment_ );
    }
  }
开发者ID:adrpo,项目名称:OMNotebook,代码行数:37,代码来源:textcursorcommands.cpp

示例5: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    //ui->setupUi(this);
    //ustvarim Widget
    centralWidget = new QWidget(this);
    this->setCentralWidget( centralWidget );
    centralWidget->setWindowTitle("DLX");
    centralWidget->setMaximumSize(1000, 1000);
    centralWidget->setMinimumSize(10, 10);
    centralWidget->resize(400,400);
    mainLayout = new QGridLayout( centralWidget );
    mainLayout->setSpacing(0);
    for(int mr = 0; mr < 3; mr++)//ustvarim 3 vrstice
    {
        for(int mc = 0; mc < 3; mc++)//ustvarim 3 stolpce
        {
            //veliki robovi
            QFrame * widget = new QFrame;
            widget->setFrameStyle(QFrame::Plain);
            widget->setFrameShape(QFrame::Box);

            //znotraj velikih robov se en grid
            QGridLayout * gridLayout = new QGridLayout(widget);
            gridLayout->setSpacing(0);
            gridLayout->setMargin(0);

            for(int r = 0; r < 3; r++)//3 vrstice
            {
                for(int c = 0; c < 3; c++)//3 stolpci
                {
                    //ustvarim skatlo s textom
                    QTextEdit * tile = new QTextEdit("");
                    tile->setFrameStyle(QFrame::Plain);
                    tile->setFrameShape(QFrame::Box);
                    tile->setAlignment(Qt::AlignCenter);
                    tile->setTabChangesFocus(true);
                    tile->setStyleSheet("font: 24pt ;");

                    gridLayout->addWidget(tile, r, c, 1, 1, Qt::AlignCenter);
                }
            }
           mainLayout->addWidget(widget, mr, mc, 1, 1, Qt::AlignCenter);
        }
    }
    //ustvarim menu z eventom
    QMenuBar* menuBar = new QMenuBar();
    QMenu *fileMenu = new QMenu("Algoritem");
    menuBar->addMenu(fileMenu);
    QAction *helpAction = fileMenu->addAction("Find solution");
    connect(helpAction, SIGNAL(triggered()), this, SLOT(algoritem()));
    centralWidget->layout()->setMenuBar(menuBar);
    QMenu *fileMenu1 = new QMenu("Input");
    menuBar->addMenu(fileMenu1);
    QAction *Action = fileMenu1->addAction("Reset");
    connect(Action, SIGNAL(triggered()), this, SLOT(reset()));
    QAction *Action2 = fileMenu1->addAction("Qassim Hamza");
    connect(Action2, SIGNAL(triggered()), this, SLOT(hamza()));
}
开发者ID:nejcgalof,项目名称:Sudoku-solver-with-algorithm-DLX,代码行数:60,代码来源:mainwindow.cpp

示例6: on_actionFullJustify_triggered

void MainWindow::on_actionFullJustify_triggered()
{
    QTextEdit *pEdit = textEditor.editor;
    pEdit->setAlignment(Qt::AlignJustify);
    groupCheck(3);
}
开发者ID:KanagiMiss,项目名称:testassist,代码行数:6,代码来源:mainwindow.cpp

示例7: on_actionCenter_triggered

void MainWindow::on_actionCenter_triggered()
{
    QTextEdit *pEdit = textEditor.editor;
    pEdit->setAlignment(Qt::AlignHCenter);
    groupCheck(0);
}
开发者ID:KanagiMiss,项目名称:testassist,代码行数:6,代码来源:mainwindow.cpp

示例8: on_actionRightAlign_triggered

void MainWindow::on_actionRightAlign_triggered()
{
    QTextEdit *pEdit = textEditor.editor;
    pEdit->setAlignment(Qt::AlignRight | Qt::AlignAbsolute);
    groupCheck(1);
}
开发者ID:KanagiMiss,项目名称:testassist,代码行数:6,代码来源:mainwindow.cpp

示例9: 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


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