本文整理汇总了C++中QPlainTextEdit::setStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:C++ QPlainTextEdit::setStyleSheet方法的具体用法?C++ QPlainTextEdit::setStyleSheet怎么用?C++ QPlainTextEdit::setStyleSheet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPlainTextEdit
的用法示例。
在下文中一共展示了QPlainTextEdit::setStyleSheet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logToConsole
void DevConsole::logToConsole(const QString &logText, const QString &channel, bool raise)
{
QString target_channel = channel;
if(channel == "System") //Prevent creation another "system" tab if switched another UI language
target_channel = ui->tabWidget->tabText(0);
for(int i = 0; i < ui->tabWidget->count(); ++i)
{
if(ui->tabWidget->tabText(i) == target_channel)
{
QPlainTextEdit *tarEdit = getEditByIndex(i);
if(!tarEdit)
return;
tarEdit->appendPlainText(logText);
tarEdit->verticalScrollBar()->setValue(tarEdit->verticalScrollBar()->maximum());
if(raise) ui->tabWidget->setCurrentIndex(i);
return;
}
}
//create new channel
QWidget *w = new QWidget();
QGridLayout *l = new QGridLayout(w);
l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0);
QPlainTextEdit *e = new QPlainTextEdit(w);
l->addWidget(e, 0, 0, 1, 1);
QPushButton *p = new QPushButton(w);
l->addWidget(p, 1, 0, 1, 1);
p->setFlat(true);
p->connect(p, SIGNAL(clicked()), this, SLOT(clearCurrentLog()));
p->setText(tr("Clear %1 Log").arg(target_channel));
e->setReadOnly(true);
e->setStyleSheet(ui->plainTextEdit->styleSheet());
e->setFont(ui->plainTextEdit->font());
e->appendPlainText(logText);
e->verticalScrollBar()->setValue(e->verticalScrollBar()->maximum());
ui->tabWidget->addTab(w, target_channel);
}