当前位置: 首页>>代码示例>>C++>>正文


C++ QPlainTextEdit::setReadOnly方法代码示例

本文整理汇总了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;
}
开发者ID:mogaal,项目名称:nomnom,代码行数:58,代码来源:nerrorwhiledialog.cpp

示例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);
}
开发者ID:hacheipe399,项目名称:PlatGEnWohl,代码行数:29,代码来源:devconsole.cpp

示例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;
}
开发者ID:gabrielelanaro,项目名称:avogadro,代码行数:33,代码来源:qperiodictable.cpp

示例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 {
开发者ID:Revulet,项目名称:qtcreator,代码行数:26,代码来源:qmlengine.cpp

示例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 &nbsp; <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();
        }
开发者ID:DevasenaInupakutika,项目名称:assn2,代码行数:33,代码来源:main.cpp

示例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);
}
开发者ID:1h6,项目名称:ProjectTox-Qt-GUI,代码行数:35,代码来源:friendrequestdialog.cpp

示例7: loadMaster

QList<RewriterView::Error> DesignDocumentController::loadMaster(const QByteArray &qml)
{
    QPlainTextEdit *textEdit = new QPlainTextEdit;
    textEdit->setReadOnly(true);
    textEdit->setPlainText(QString(qml));
    return loadMaster(textEdit);
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例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 &nbsp;&nbsp;&nbsp; %3 &nbsp;&nbsp;&nbsp;</font>" )
                   .arg( color.name(), QDateTime::currentDateTime().toString( Qt::ISODate ), levelString );
  QString cleanedMessage = message;
  cleanedMessage = cleanedMessage.prepend( prefix ).replace( '\n', QLatin1String( "<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;" ) );
  w->appendHtml( cleanedMessage );
  w->verticalScrollBar()->setValue( w->verticalScrollBar()->maximum() );
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:57,代码来源:qgsmessagelogviewer.cpp

示例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() );
}
开发者ID:peterisb,项目名称:QGIS,代码行数:50,代码来源:qgsmessagelogviewer.cpp

示例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);
}
开发者ID:josephstill,项目名称:chip-8,代码行数:15,代码来源:HexDumpWindow.cpp

示例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;
}
开发者ID:nullcoding,项目名称:sqlcomps,代码行数:15,代码来源:dbg.cpp

示例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()));
}
开发者ID:manitou-mail,项目名称:manitou-mail-ui,代码行数:45,代码来源:db_error_dialog.cpp

示例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();
}
开发者ID:KubaO,项目名称:stackoverflown,代码行数:18,代码来源:main.cpp

示例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);
}
开发者ID:Dead133,项目名称:obs-studio,代码行数:44,代码来源:scripts.cpp

示例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()));
}
开发者ID:dubhater,项目名称:LibreLibreCell,代码行数:43,代码来源:about.cpp


注:本文中的QPlainTextEdit::setReadOnly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。