Qt入門-テキストボックスクラスQLineEditとQTextEdit
1481 ワード
QLineEditは、単行テキストボックスです.
QTextEditは、複数行のテキストボックスです.
(1)単行テキストボックスQLineEdit
一般的なメソッドとプロパティ:
(a)テキストの位置合わせの取得と設定
(b)ファイルボックスの内容の取得と設定
(c)選択したテキストの取得と設定
(d)echoModeモードの取得と設定
echoModeモードの値は次のとおりです.
(2)複数行テキストボックスQTextEdit QTextEditは複数行のテキスト内容を表示し、テキスト内容がコントロール表示範囲を超えた場合、水平スクロールバーと垂直スクロールバーを表示することができる.
acceptRichTextプロパティを設定することで、QTextEditは文字だけでなく、HTMLドキュメント、画像、表などの要素も表示できます.
例:
(1)複数行のテキストボックスの内容を設定する:
(2)複数行のテキストボックスの内容を取得する:
QTextEditは、複数行のテキストボックスです.
(1)単行テキストボックスQLineEdit
一般的なメソッドとプロパティ:
(a)テキストの位置合わせの取得と設定
Qt::Alignment alignment () const
void setAlignment ( Qt::Alignment flag )
(b)ファイルボックスの内容の取得と設定
QString text () const
void setText ( const QString & )
(c)選択したテキストの取得と設定
QString selectedText () const
void QLineEdit::setSelection ( int start, int length )
(d)echoModeモードの取得と設定
EchoMode echoMode () const
void setEchoMode ( EchoMode )
echoModeモードの値は次のとおりです.
QLineEdit::Normal 0 Display characters as they are entered. This is the default.
QLineEdit::NoEcho 1 Do not display anything. This may be appropriate for passwords where even the length of the password should be kept secret.
QLineEdit::Password 2 Display asterisks instead of the characters actually entered.
QLineEdit::PasswordEchoOnEdit 3 Display characters as they are entered while editing otherwise display asterisks.
(2)複数行テキストボックスQTextEdit QTextEditは複数行のテキスト内容を表示し、テキスト内容がコントロール表示範囲を超えた場合、水平スクロールバーと垂直スクロールバーを表示することができる.
acceptRichTextプロパティを設定することで、QTextEditは文字だけでなく、HTMLドキュメント、画像、表などの要素も表示できます.
例:
(1)複数行のテキストボックスの内容を設定する:
textEdt->setPlainText("12345
abcdef");
(2)複数行のテキストボックスの内容を取得する:
QString str;
str = textEdt->toPlainText();