本文整理汇总了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();
}
示例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();
}
示例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());
}
示例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_ );
}
}
示例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()));
}
示例6: on_actionFullJustify_triggered
void MainWindow::on_actionFullJustify_triggered()
{
QTextEdit *pEdit = textEditor.editor;
pEdit->setAlignment(Qt::AlignJustify);
groupCheck(3);
}
示例7: on_actionCenter_triggered
void MainWindow::on_actionCenter_triggered()
{
QTextEdit *pEdit = textEditor.editor;
pEdit->setAlignment(Qt::AlignHCenter);
groupCheck(0);
}
示例8: on_actionRightAlign_triggered
void MainWindow::on_actionRightAlign_triggered()
{
QTextEdit *pEdit = textEditor.editor;
pEdit->setAlignment(Qt::AlignRight | Qt::AlignAbsolute);
groupCheck(1);
}
示例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);
}
}
//.........这里部分代码省略.........