本文整理汇总了C++中QTextEdit::textColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::textColor方法的具体用法?C++ QTextEdit::textColor怎么用?C++ QTextEdit::textColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::textColor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: textColor
int TextEdit::textColor(lua_State * L) // const : QColor
{
QTextEdit* obj = ObjectHelper<QTextEdit>::check( L, 1);
QColor* res = ValueInstaller2<QColor>::create( L );
*res = obj->textColor();
return 1;
}
示例2: textColor
QColor QTextEditProto::textColor() const
{
QTextEdit *item = qscriptvalue_cast<QTextEdit*>(thisObject());
if (item)
return item->textColor();
return QColor();
}
示例3: on_actionChangeFontColor_triggered
void MainWindow::on_actionChangeFontColor_triggered()
{
QTextEdit *pEdit = textEditor.editor;
QColor col = QColorDialog::getColor(pEdit->textColor(), this);
if (!col.isValid())
return;
QTextCharFormat fmt;
fmt.setForeground(col);
mergeFormatOnWordOrSelection(fmt);
colorChanged(col);
}
示例4: eventFilter
bool EmulApp::eventFilter(QObject *watched, QEvent *event)
{
int type = static_cast<int>(event->type());
if (type == QEvent::KeyPress) {
}
MainWindow *mw = dynamic_cast<MainWindow *>(watched);
if (mw) {
if (type == LogLineEventType) {
LogLineEvent *evt = dynamic_cast<LogLineEvent *>(event);
if (evt && mw->textEdit()) {
QTextEdit *te = mw->textEdit();
QColor origcolor = te->textColor();
te->setTextColor(evt->color);
te->append(evt->str);
// make sure the log textedit doesn't grow forever
// so prune old lines when a threshold is hit
nLinesInLog += evt->str.split("\n").size();
if (nLinesInLog > nLinesInLogMax) {
const int n2del = MAX(nLinesInLogMax/10, nLinesInLog-nLinesInLogMax);
QTextCursor cursor = te->textCursor();
cursor.movePosition(QTextCursor::Start);
for (int i = 0; i < n2del; ++i) {
cursor.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor);
}
cursor.removeSelectedText(); // deletes the lines, leaves a blank line
nLinesInLog -= n2del;
}
te->setTextColor(origcolor);
te->moveCursor(QTextCursor::End);
te->ensureCursorVisible();
return true;
} else {
return false;
}
} else if (type == StatusMsgEventType) {
StatusMsgEvent *evt = dynamic_cast<StatusMsgEvent *>(event);
if (evt && mw->statusBar()) {
mw->statusBar()->showMessage(evt->msg, evt->timeout);
return true;
} else {
return false;
}
}
}
if (watched == this) {
if (type == QuitEventType) {
quit();
return true;
}
if (type == SoundTrigEventType) {
SoundTrigEvent *evt = dynamic_cast<SoundTrigEvent *>(event);
if (evt) trigSound(evt->trig);
if (evt->listener) evt->listener->triggered(evt->trig);
return true;
}
if (type == SoundEventType) {
SoundEvent *evt = dynamic_cast<SoundEvent *>(event);
if (evt) gotSound(evt->id, evt->name, evt->loops);
if (evt->listener) evt->listener->gotSound(evt->id);
return true;
}
}
// otherwise do default action for event which probably means
// propagate it down
return QApplication::eventFilter(watched, event);
}