Ejemplo n.º 1
0
void MainWindow::openFile()
{
    QString fileName = QFileDialog::getOpenFileName(this);
    if (!fileName.isEmpty())
    {
        QsciScintilla * editor = new QsciScintilla();
        editor->setPaper(QColor(1,81,107));
        editor->setMarginLineNumbers(1,true);
        editor->setAutoIndent(true);
        editor->setLexer(new QsciLexerPython());
        editor->setFolding(QsciScintilla::PlainFoldStyle);
        editor->setAutoCompletionThreshold(2);
        editor->setAutoCompletionSource(QsciScintilla::AcsAll);
        ui->tabWidget->addTab(editor, QIcon(), fileName);

        QFile file(fileName);
        if (!file.open(QFile::ReadOnly)) {
            QMessageBox::warning(this, tr("Application"),
                                tr("Cannot read file %1:\n%2.")
                                .arg(fileName)
                                .arg(file.errorString()));
            return;
        }

        QTextStream in(&file);
        QApplication::setOverrideCursor(Qt::WaitCursor);
        editor->setText(in.readAll());
        QApplication::restoreOverrideCursor();

        //setCurrentFile(fileName);
        //statusBar()->showMessage(tr("File loaded"), 2000);
    }
}
Ejemplo n.º 2
0
void MainWindow::newFile()
{
    QsciScintilla * editor = new QsciScintilla();
    editor->setPaper(QColor(1,81,107));
    editor->setMarginLineNumbers(1,true);
    editor->setAutoIndent(true);
    editor->setLexer(new QsciLexerPython());
    editor->setFolding(QsciScintilla::PlainFoldStyle);
    editor->setAutoCompletionThreshold(2);
    editor->setAutoCompletionSource(QsciScintilla::AcsAll);
    ui->tabWidget->addTab(editor, QIcon(), QString("New file"));

}