本文整理汇总了C++中QPlainTextEdit::verticalScrollBar方法的典型用法代码示例。如果您正苦于以下问题:C++ QPlainTextEdit::verticalScrollBar方法的具体用法?C++ QPlainTextEdit::verticalScrollBar怎么用?C++ QPlainTextEdit::verticalScrollBar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPlainTextEdit
的用法示例。
在下文中一共展示了QPlainTextEdit::verticalScrollBar方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logToConsole
void DevConsole::logToConsole(const QString &logText, const QString &channel, bool raise)
{
for(int i = 0; i < ui->tabWidget->count(); ++i){
if(ui->tabWidget->tabText(i)==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);
connect(p, SIGNAL(clicked()), this, SLOT(clearCurrentLog()));
p->setText(tr("Clear %1 Log").arg(channel));
e->setReadOnly(true);
e->appendPlainText(logText);
e->verticalScrollBar()->setValue(e->verticalScrollBar()->maximum());
ui->tabWidget->addTab(w,channel);
}
示例2: sinkMessage
void MessagesDialog::sinkMessage( const MsgEvent *msg )
{
QMutexLocker locker( &messageLocker );
QPlainTextEdit *messages = ui.messages;
/* Only scroll if the viewport is at the end.
Don't bug user by auto-changing/losing viewport on insert(). */
bool b_autoscroll = ( messages->verticalScrollBar()->value()
+ messages->verticalScrollBar()->pageStep()
>= messages->verticalScrollBar()->maximum() );
/* Copy selected text to the clipboard */
if( messages->textCursor().hasSelection() )
messages->copy();
/* Fix selected text bug */
if( !messages->textCursor().atEnd() ||
messages->textCursor().anchor() != messages->textCursor().position() )
messages->moveCursor( QTextCursor::End );
/* Start a new logic block so we can hide it on-demand */
messages->textCursor().insertBlock();
QString buf = QString( "<i><font color='darkblue'>%1</font>" ).arg( msg->module );
switch ( msg->priority )
{
case VLC_MSG_INFO:
buf += "<font color='blue'> info: </font>";
break;
case VLC_MSG_ERR:
buf += "<font color='red'> error: </font>";
break;
case VLC_MSG_WARN:
buf += "<font color='green'> warning: </font>";
break;
case VLC_MSG_DBG:
default:
buf += "<font color='grey'> debug: </font>";
break;
}
/* Insert the prefix */
messages->textCursor().insertHtml( buf /* + "</i>" */ );
/* Insert the message */
messages->textCursor().insertHtml( msg->text );
/* Pass the new message thru the filter */
QTextBlock b = messages->document()->lastBlock();
b.setVisible( matchFilter( b.text() ) );
/* Tell the QTextDocument to recompute the size of the given area */
messages->document()->markContentsDirty( b.position(), b.length() );
if ( b_autoscroll ) messages->ensureCursorVisible();
}
示例3: logMessage
void QgsMessageLogViewer::logMessage( const QString &message, const QString &tag, Qgis::MessageLevel level )
{
QString cleanedTag = tag;
if ( cleanedTag.isNull() )
cleanedTag = tr( "General" );
int i;
for ( i = 0; i < tabWidget->count() && tabWidget->tabText( i ).remove( QChar( '&' ) ) != cleanedTag; i++ );
QPlainTextEdit *w = nullptr;
if ( i < tabWidget->count() )
{
w = qobject_cast<QPlainTextEdit *>( tabWidget->widget( i ) );
tabWidget->setCurrentIndex( i );
}
else
{
w = new QPlainTextEdit( this );
w->setReadOnly( true );
tabWidget->addTab( w, cleanedTag );
tabWidget->setCurrentIndex( tabWidget->count() - 1 );
}
QString levelString;
QgsSettings settings;
QColor color;
switch ( level )
{
case Qgis::Info:
levelString = QStringLiteral( "INFO" );
color = QColor( settings.value( QStringLiteral( "colors/info" ), QStringLiteral( "#000000" ) ).toString() );
break;
case Qgis::Warning:
levelString = QStringLiteral( "WARNING" );
color = QColor( settings.value( QStringLiteral( "colors/warning" ), QStringLiteral( "#000000" ) ).toString() );
break;
case Qgis::Critical:
levelString = QStringLiteral( "CRITICAL" );
color = QColor( settings.value( QStringLiteral( "colors/critical" ), QStringLiteral( "#000000" ) ).toString() );
break;
case Qgis::Success:
levelString = QStringLiteral( "SUCCESS" );
color = QColor( settings.value( QStringLiteral( "colors/success" ), QStringLiteral( "#000000" ) ).toString() );
break;
case Qgis::None:
levelString = QStringLiteral( "NONE" );
color = QColor( settings.value( QStringLiteral( "colors/default" ), QStringLiteral( "#000000" ) ).toString() );
break;
}
QString prefix = QStringLiteral( "<font color=\"%1\">%2 %3 </font>" )
.arg( color.name(), QDateTime::currentDateTime().toString( Qt::ISODate ), levelString );
QString cleanedMessage = message;
cleanedMessage = cleanedMessage.prepend( prefix ).replace( '\n', QLatin1String( "<br> " ) );
w->appendHtml( cleanedMessage );
w->verticalScrollBar()->setValue( w->verticalScrollBar()->maximum() );
}
示例4: logMessage
void QgsMessageLogViewer::logMessage( const QString &message, const QString &tag, QgsMessageLog::MessageLevel level )
{
QString cleanedTag = tag;
if ( cleanedTag.isNull() )
cleanedTag = tr( "General" );
int i;
for ( i = 0; i < tabWidget->count() && tabWidget->tabText( i ) != cleanedTag; i++ )
;
QPlainTextEdit *w = nullptr;
if ( i < tabWidget->count() )
{
w = qobject_cast<QPlainTextEdit *>( tabWidget->widget( i ) );
tabWidget->setCurrentIndex( i );
}
else
{
w = new QPlainTextEdit( this );
w->setReadOnly( true );
tabWidget->addTab( w, cleanedTag );
tabWidget->setCurrentIndex( tabWidget->count() - 1 );
tabWidget->setTabsClosable( true );
}
QString levelString;
switch ( level )
{
case QgsMessageLog::INFO:
levelString = "INFO";
break;
case QgsMessageLog::WARNING:
levelString = "WARNING";
break;
case QgsMessageLog::CRITICAL:
levelString = "CRITICAL";
break;
case QgsMessageLog::NONE:
levelString = "NONE";
break;
}
QString prefix = QStringLiteral( "%1\t%2\t" )
.arg( QDateTime::currentDateTime().toString( Qt::ISODate ) )
.arg( levelString );
QString cleanedMessage = message;
cleanedMessage = cleanedMessage.prepend( prefix ).replace( '\n', QLatin1String( "\n\t\t\t" ) );
w->appendPlainText( cleanedMessage );
w->verticalScrollBar()->setValue( w->verticalScrollBar()->maximum() );
}
示例5: showMessage
void StateMachineViewerWidget::showMessage(const QString &message)
{
// update log
QPlainTextEdit *plainTextEdit = m_ui->plainTextEdit;
plainTextEdit->appendPlainText(message);
// auto-scroll hack
QScrollBar *sb = plainTextEdit->verticalScrollBar();
sb->setValue(sb->maximum());
}
示例6: logMessage
void QgsMessageLogViewer::logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level )
{
#ifdef ANDROID
mButton->setToolTip( tr( "Message(s) logged." ) );
#endif
if ( !isVisible() && level > QgsMessageLog::INFO )
{
mButton->show();
if ( mShowToolTips )
QToolTip::showText( mButton->mapToGlobal( QPoint( 0, 0 ) ), mButton->toolTip() );
}
if ( tag.isNull() )
tag = tr( "General" );
int i;
for ( i = 0; i < tabWidget->count() && tabWidget->tabText( i ) != tag; i++ )
;
QPlainTextEdit *w;
if ( i < tabWidget->count() )
{
w = qobject_cast<QPlainTextEdit *>( tabWidget->widget( i ) );
tabWidget->setCurrentIndex( i );
}
else
{
w = new QPlainTextEdit( this );
w->setReadOnly( true );
tabWidget->addTab( w, tag );
tabWidget->setCurrentIndex( tabWidget->count() - 1 );
}
QString prefix = QString( "%1\t%2\t")
.arg( QDateTime::currentDateTime().toString( Qt::ISODate ) )
.arg( level );
w->appendPlainText( message.prepend( prefix ).replace( "\n", "\n\t\t\t" ) );
w->verticalScrollBar()->setValue( w->verticalScrollBar()->maximum() );
}
示例7: 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);
}
示例8: QWidget
ScriptLogWindow::ScriptLogWindow() : QWidget(nullptr)
{
const QFont fixedFont =
QFontDatabase::systemFont(QFontDatabase::FixedFont);
QPlainTextEdit *edit = new QPlainTextEdit();
edit->setReadOnly(true);
edit->setFont(fixedFont);
edit->setWordWrapMode(QTextOption::NoWrap);
QHBoxLayout *buttonLayout = new QHBoxLayout();
QPushButton *clearButton = new QPushButton(tr("Clear"));
connect(clearButton, &QPushButton::clicked,
this, &ScriptLogWindow::ClearWindow);
QPushButton *closeButton = new QPushButton(tr("Close"));
connect(closeButton, &QPushButton::clicked,
this, &QDialog::hide);
buttonLayout->addStretch();
buttonLayout->addWidget(clearButton);
buttonLayout->addWidget(closeButton);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(edit);
layout->addLayout(buttonLayout);
setLayout(layout);
scriptLogWidget = edit;
resize(600, 400);
config_t *global_config = obs_frontend_get_global_config();
const char *geom = config_get_string(global_config,
"ScriptLogWindow", "geometry");
if (geom != nullptr) {
QByteArray ba = QByteArray::fromBase64(QByteArray(geom));
restoreGeometry(ba);
}
setWindowTitle(obs_module_text("ScriptLogWindow"));
connect(edit->verticalScrollBar(), &QAbstractSlider::sliderMoved,
this, &ScriptLogWindow::ScrollChanged);
}