本文整理汇总了C++中QTextEdit::setFocusPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::setFocusPolicy方法的具体用法?C++ QTextEdit::setFocusPolicy怎么用?C++ QTextEdit::setFocusPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::setFocusPolicy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QLabel
RKReadLineDialog::RKReadLineDialog (QWidget *parent, const QString &caption, const QString &prompt, RCommand *command) : KDialogBase (parent, 0, true, caption, KDialogBase::Ok | KDialogBase::Cancel) {
RK_TRACE (DIALOGS);
RK_ASSERT (command);
QVBox *page = makeVBoxMainWidget ();
new QLabel (caption, page);
int screen_width = qApp->desktop ()->width () - 2*marginHint() - 2*spacingHint (); // TODO is this correct on xinerama?
QString context = command->fullOutput ();
if (!context.isEmpty ()) {
new QLabel (i18n ("Context:"), page);
QTextEdit *output = new QTextEdit (page);
output->setUndoRedoEnabled (false);
output->setTextFormat (QTextEdit::PlainText);
output->setCurrentFont (QFont ("Courier"));
output->setWordWrap (QTextEdit::NoWrap);
output->setText (context);
output->setReadOnly (true);
int cwidth = output->contentsWidth ();
output->setMinimumWidth (screen_width < cwidth ? screen_width : cwidth);
output->scrollToBottom ();
output->setFocusPolicy (QWidget::NoFocus);
}
QLabel *promptl = new QLabel (prompt, page);
promptl->setAlignment (Qt::WordBreak | promptl->alignment ());
input = new QLineEdit (QString (), page);
input->setMinimumWidth (fontMetrics ().maxWidth ()*20);
input->setFocus ();
}
示例2: setMessages
void UBMessagesDialog::setMessages(const QList<QString> messages)
{
mMessages = messages;
if (mMessages.count())
{
QVBoxLayout *messagesLayout = new QVBoxLayout(this);
foreach (QString message, mMessages)
{
QTextEdit *messageBox = new QTextEdit(this);
messageBox->setMinimumHeight(55);
messageBox->setReadOnly(true);
messageBox->setFocusPolicy(Qt::NoFocus);
messageBox->setText(message);
messagesLayout->addWidget(messageBox);
}
示例3: initDisplay
//.........这里部分代码省略.........
//
int userName_x = tests_x;
int userName_y = tests_y + text_h + (4 * vs);
int userNameEd_x = userName_x + text_w;
int userNameEd_w = 250;
userNameLabel = new QLabel(this);
userNameLabel->setGeometry(userName_x, userName_y, text_w, text_h);
userNameLabel->setText("Your Name:");
userNameEdit = new QLineEdit(this);
userNameEdit->setGeometry(userNameEd_x, userName_y, userNameEd_w, box_h);
userNameEdit->setText("");
userNameEdit->setCursorPosition(0);
connect(userNameEdit, SIGNAL(returnPressed()), this, SLOT(onUserName()));
// Create and connect the Start button.
// Because this pushbutton's parent is QDialog, it will have its
// autoDefault property set when instantiated. This can cause some very
// confusing behavior if you don't know this. See "autoDefault" in the
// QPushButton class reference. We will explicitly set this property
// to FALSE for this button, and also set its "default" property to
// FALSE.
//
const int pbw = 100;
const int pbhs = 110;
int goButton_x = tests_x+10;
int goButton_y = userName_y + vs + 6;
goButton = new QPushButton("Start", this);
goButton->setGeometry(goButton_x, goButton_y, pbw, box_h);
goButton->setAutoDefault(false);
goButton->setDefault(false);
connect(goButton, SIGNAL(clicked()), this, SLOT(onGo()));
// Create and connect the stop button.
//
int stopButton_x = goButton_x + pbhs;
int stopButton_y = goButton_y;
stopButton = new QPushButton("Stop", this);
stopButton->setGeometry(stopButton_x, stopButton_y, pbw, box_h);
stopButton->setAutoDefault(false);
stopButton->setDefault(false);
connect(stopButton, SIGNAL(clicked()), this, SLOT(onStop()));
// Create and connect the Default button.
//
int defaultButton_x = stopButton_x + pbhs;
int defaultButton_y = goButton_y;
defaultButton = new QPushButton("Defaults", this);
defaultButton->setGeometry(defaultButton_x, defaultButton_y, pbw, box_h);
defaultButton->setAutoDefault(false);
defaultButton->setDefault(false);
connect(defaultButton, SIGNAL(clicked()), this, SLOT(onDefault()));
// Layout the Quiz and Answer Boxes and their labels
//
tw = new Twidget;
int quiz_x = tests_x + 20;
int quiz_y = goButton_y + vs;
LAYOUT(quiz_x, quiz_y, hs + box_w+10, text_h)
tw->labelLayout << CELL(0,0) << CELL(1,0) << CELL(2,0)
<< CELL(0,1) << CELL(1,1) << CELL(2,1);
tw->labelText << "Problem" << "The" << "Your"
<< "Number" << "Problem" << "Answer";
tw->labelSizes << QSize(text_w, text_h);
LAYOUT(quiz_x, quiz_y+(2*text_h)+2, hs + box_w+10, 0)
tw->objName = "Quiz";
tw->objText << "";
tw->sizes << QSize(box_w, box_h)
<< QSize(box_w+30, box_h)
<< QSize(box_w+10, box_h);
tw->hOffset << 20 << -5 << 0 << 20 << -5 << 0;
tw->layout << CELL(0,0) << CELL(1,0) << CELL(2,0);
pQuiz = new TEditGroup <QLineEdit>(tw, this);
//
// Set the Quiz Box to ReadOnly and connect the returnPressed
// signal from the Answer Box.
//
pQuiz->widgetList[qz_number]->setReadOnly(true);
pQuiz->widgetList[qz_number]->setAlignment(Qt::AlignRight);
pQuiz->widgetList[qz_quiz]->setReadOnly(true);
pQuiz->widgetList[qz_answer]->setEnabled(true);
pQuiz->widgetList[qz_answer]->setInputMask("0000");
pQuiz->widgetList[qz_answer]->setCursor(Qt::IBeamCursor);
pQuiz->widgetList[qz_answer]->setCursorPosition(0);
QLineEdit *tempLineEdit = pQuiz->widgetList[qz_answer];
connect (tempLineEdit, SIGNAL(returnPressed()),
this, SLOT(onAnswer()));
// Create the Message Box
//
int msg_x = tests_x;
int msg_y = quiz_y + vs + (3 * text_h);
int msg_w = 340;
int msg_h = 180;
QTextEdit* messages = new QTextEdit(this);
messages->setGeometry(msg_x, msg_y, msg_w, msg_h);
messages->setReadOnly(true);
messages->setFocusPolicy(Qt::ClickFocus);
messages->setUpdatesEnabled(true);
pMsg = new Msg(messages);
}