本文整理汇总了C++中QPlainTextEdit::setReadOnly方法的典型用法代码示例。如果您正苦于以下问题:C++ QPlainTextEdit::setReadOnly方法的具体用法?C++ QPlainTextEdit::setReadOnly怎么用?C++ QPlainTextEdit::setReadOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPlainTextEdit
的用法示例。
在下文中一共展示了QPlainTextEdit::setReadOnly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
NErrorWhileDialog::NErrorWhileDialog(const QStringList& args,
const QString& errmsg,
const int errcode,
QWidget *parent)
: QDialog(parent)
{
QVBoxLayout *box = new QVBoxLayout;
// Label
QLabel *l = new QLabel(label(ErrorWhileRunning));
box->addWidget(l);
// Command args
QPlainTextEdit *t = new QPlainTextEdit(this);
t->setPlainText(args.join(" "));
t->setReadOnly(true);
box->addWidget(t);
// Label
l = new QLabel(label(ErrorMessageFollows));
box->addWidget(l);
// Error message
t = new QPlainTextEdit(this);
const QString s = label(ErrorCode, QString("%1").arg(errcode));
t->setPlainText(QString("%1\n%2").arg(errmsg).arg(s));
t->setReadOnly(true);
box->addWidget(t);
// Button box
QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
QPushButton *b = new QPushButton(tr("Co&py"));
b->setToolTip(tr("Copy to clipboard"));
bb->addButton(b, QDialogButtonBox::ActionRole);
connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
connect(b, SIGNAL(clicked()), this, SLOT(copy()));
box->addWidget(bb);
// Window
setFixedSize(QSize(400,340));
setWindowTitle(tr("Error"));
setLayout(box);
show();
// Save
_errcode = errcode;
_errmsg = errmsg;
_args = args;
}
示例2: 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);
}
示例3: main
int main(int argc, char **argv)
{
QApplication app(argc, argv);
// Load the Periodic Table translations
QPointer <QTranslator> ptTranslator = QPeriodicTable::createTranslator();
if (ptTranslator)
qApp->installTranslator(ptTranslator);
// Construct Periodic Table
PeriodicTableView* periodicTable = new PeriodicTableView;
periodicTable->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QMainWindow *window = new QMainWindow();
window->setWindowTitle("Periodic System of D.I.Mendeleyev");
QWidget *widget = new QWidget;
QHBoxLayout *layout = new QHBoxLayout(widget);
widget->setLayout(layout);
QPlainTextEdit *elementInfo = new QPlainTextEdit;
elementInfo->setReadOnly(true);
elementInfo->setPlainText("Click on element to get the information about it");
elementInfo->setMaximumHeight(periodicTable->height());
elementInfo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
layout->addWidget(periodicTable);
layout->addWidget(elementInfo);
window->setCentralWidget(widget);
PeriodicTableWatcher *watcher = new PeriodicTableWatcher(periodicTable, elementInfo);
window->show();
app.exec();
delete periodicTable;
delete elementInfo;
delete window;
return 0;
}
示例4: gotoLocation
void QmlEngine::gotoLocation(const Location &location)
{
const QString fileName = location.fileName();
if (QUrl(fileName).isLocalFile()) {
// internal file from source files -> show generated .js
QTC_ASSERT(m_sourceDocuments.contains(fileName), return);
QString titlePattern = tr("JS Source for %1").arg(fileName);
//Check if there are open documents with the same title
foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) {
if (document->displayName() == titlePattern) {
Core::EditorManager::activateEditorForDocument(document);
return;
}
}
Core::IEditor *editor = Core::EditorManager::openEditorWithContents(
QmlJSEditor::Constants::C_QMLJSEDITOR_ID, &titlePattern);
if (editor) {
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
QPlainTextEdit *plainTextEdit =
qobject_cast<QPlainTextEdit *>(editor->widget());
if (plainTextEdit)
plainTextEdit->setReadOnly(true);
updateDocument(editor->document(), m_sourceDocuments.value(fileName));
}
} else {
示例5: catchException
void catchException(const std::exception& ex) {
QString error = QString::fromUtf8(ex.what());
QString message = "<qt><b>qtfuzzylite</b> has experienced an internal error and will exit.<br><br>"
"Please report this error to <a href='mailto:[email protected]'>"
"[email protected]</a><br><br>"
"Your report will help to make <b>fuzzylite</b> and <b>qtfuzzylite</b> a better "
"free open source fuzzy logic library!<br><br>"
"Many thanks in advance for your help!"
"</qt>";
QMessageBox x(NULL);
x.setText(message);
x.setWindowTitle("Internal Error");
x.setIcon(QMessageBox::Critical);
QLabel dummy;
x.layout()->addWidget(&dummy);
QLabel viewLabel("Error message:");
QPlainTextEdit viewError;
viewError.setReadOnly(true);
viewError.setPlainText(error);
viewError.setLineWrapMode(QPlainTextEdit::NoWrap);
QFont tt("?");
tt.setStyleHint(QFont::TypeWriter);
tt.setPointSize(tt.pointSize() - 2);
viewError.setFont(tt);
QWidget* view = new QWidget;
view->setLayout(new QVBoxLayout);
view->layout()->addWidget(&viewLabel);
view->layout()->addWidget(&viewError);
x.layout()->addWidget(view);
x.exec();
}
示例6: QDialog
FriendRequestDialog::FriendRequestDialog(QWidget *parent, const QString &userId, const QString &message) :
QDialog(parent)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle("Friend request");
QLabel *friendsLabel = new QLabel("Someone wants to make friends with you.", this);
QLabel *userIdLabel = new QLabel("User ID:", this);
QLineEdit *userIdEdit = new QLineEdit(userId, this);
userIdEdit->setReadOnly(true);
QLabel *messageLabel = new QLabel("Friend request message:", this);
QPlainTextEdit *messageEdit = new QPlainTextEdit(message, this);
messageEdit->setReadOnly(true);
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
buttonBox->addButton("Accept", QDialogButtonBox::AcceptRole);
buttonBox->addButton("Reject", QDialogButtonBox::RejectRole);
connect(buttonBox, &QDialogButtonBox::accepted, this, &FriendRequestDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &FriendRequestDialog::reject);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(friendsLabel);
layout->addSpacing(12);
layout->addWidget(userIdLabel);
layout->addWidget(userIdEdit);
layout->addWidget(messageLabel);
layout->addWidget(messageEdit);
layout->addWidget(buttonBox);
resize(300, 200);
}
示例7: loadMaster
QList<RewriterView::Error> DesignDocumentController::loadMaster(const QByteArray &qml)
{
QPlainTextEdit *textEdit = new QPlainTextEdit;
textEdit->setReadOnly(true);
textEdit->setPlainText(QString(qml));
return loadMaster(textEdit);
}
示例8: 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() );
}
示例9: 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() );
}
示例10: QWidget
HexDumpWindow::HexDumpWindow(QString romFilePath, QWidget * parent) : QWidget(parent, Qt::Window)
{
this->setWindowTitle(tr("Hex Dump"));
QString dump = QString::fromStdString(disassembler::RomParser::hexDump(romFilePath.toStdString()));
QPlainTextEdit* editor = new QPlainTextEdit(dump);
editor->setFont(QFont ("Courier", 11));
editor->setReadOnly(true);
QHBoxLayout* layout = new QHBoxLayout;
layout->addWidget(editor);
this->setLayout(layout);
this->setFixedSize(600, 600);
}
示例11: QVBoxLayout
DebugWidget::DebugWidget()
{
this->setWindowTitle("Debug Log");
this->setAttribute( Qt::WA_QuitOnClose, false ); //quit only when main window is closed
QBoxLayout* layout = new QVBoxLayout();
this->setLayout(layout);
QPlainTextEdit *textEdit = new QPlainTextEdit(this);
QFont font = QFont("Monospace");
font.setStyleHint(QFont::TypeWriter);
textEdit->setFont(font);
textEdit->setReadOnly(true);
layout->addWidget(textEdit);
this->show();
DEBUG_DISPLAY = textEdit;
}
示例12: setWindowTitle
db_error_dialog::db_error_dialog(const QString error) : m_error_text(error)
{
setWindowTitle(tr("Database error"));
QVBoxLayout* layout = new QVBoxLayout(this);
setMinimumWidth(400); // reasonable minimum
QPlainTextEdit* label = new QPlainTextEdit;
label->setPlainText(error);
label->setReadOnly(true);
label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
label->setFrameShape(QFrame::Box);
label->setFrameShadow(QFrame::Raised);
layout->addWidget(label);
m_btn_group = new QButtonGroup(this);
QButtonGroup* g = m_btn_group;
QRadioButton* btn1 = new QRadioButton(tr("Continue"));
g->addButton(btn1, 1);
btn1->setChecked(true);
QRadioButton* btn2 = new QRadioButton(tr("Try to reconnect"));
g->addButton(btn2, 2);
QRadioButton* btn3 = new QRadioButton(tr("Quit application"));
g->addButton(btn3, 3);
layout->addWidget(btn1);
layout->addWidget(btn2);
layout->addWidget(btn3);
QPushButton* btn_OK = new QPushButton(tr("OK"));
btn_OK->setDefault(true);
QPushButton* copy_btn = new QPushButton(tr("Copy"));
QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal);
buttonBox->addButton(copy_btn, QDialogButtonBox::ActionRole);
buttonBox->addButton(btn_OK, QDialogButtonBox::AcceptRole);
layout->addWidget(buttonBox);
connect(copy_btn, SIGNAL(clicked()), this, SLOT(copy_error()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(this, SIGNAL(accepted()), this, SLOT(handle_error()));
}
示例13: main
int main(int argc, char ** argv) {
QApplication app{argc, argv};
WhatsThisSignaler sig;
QPlainTextEdit w;
w.setWindowFlags(Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint);
w.setMinimumSize(200, 200);
w.setReadOnly(true);
w.show();
sig.installOn(&w);
QObject::connect(&sig, &WhatsThisSignaler::whatsThisEvent, &w, [&w](QWidget*widget, QEvent*ev){
w.appendPlainText(QStringLiteral("%1(0x%2) \"%3\" QEvent::%4")
.arg(widget->metaObject()->className())
.arg((uintptr_t)widget, 0, 16)
.arg(widget->objectName())
.arg(toName(ev->type())));
});
return app.exec();
}
示例14: 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);
}
示例15: readme
About::About(QWidget * parent, Qt::WindowFlags f)
: QDialog(parent, f)
{
// stuff
setWindowTitle("About LibreLibreCell");
QLabel *versionLabel = new QLabel(QString("Git revision: %1").arg(LIBRELIBRECELL_VERSION));
QPlainTextEdit *aboutBox = new QPlainTextEdit;
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
QVBoxLayout *vLayout = new QVBoxLayout;
vLayout->addWidget(versionLabel);
vLayout->addWidget(aboutBox, 1);
vLayout->addSpacing(10);
vLayout->addWidget(buttonBox);
setLayout(vLayout);
aboutBox->setReadOnly(true);
aboutBox->setTabChangesFocus(true);
aboutBox->setWordWrapMode(QTextOption::NoWrap);
aboutBox->setLineWrapMode(QPlainTextEdit::NoWrap);
aboutBox->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
aboutBox->setFont(QFont("Monospace", 10));
QFile readme(":/README.txt");
if (readme.open(QIODevice::ReadOnly))
{
QTextStream stream(&readme);
aboutBox->setPlainText(stream.readAll());
readme.close();
}
else
{
aboutBox->setPlainText("Could not open README.txt.");
}
QFontMetrics fm(aboutBox->font());
aboutBox->setMinimumSize(fm.width(QLatin1Char('m')) * 76, 450);
connect(buttonBox, SIGNAL(accepted()),
this, SLOT(accept()));
}