C++ (Qt)#include "terminal.h"/* -------------------------------------------------------------------------- */ QTerminal::QTerminal () :QPlainTextEdit() { setGeometry( 20, 20, 640, 480 ); setWordWrapMode( QTextOption::WrapAnywhere ); setPalette ( QPalette( QBrush(QColor(0x00,0x00,0x00)), // windowText QBrush(QColor(0xff,0xff,0xff)), // button QBrush(QColor(0xff,0xff,0xff)), // light QBrush(QColor(0xff,0xff,0xff)), // dark QBrush(QColor(0xff,0xff,0xff)), // mid QBrush(QColor(0xff,0xff,0xff)), // text QBrush(QColor(0xff,0xff,0xff)), // bright_text QBrush(QColor(0x00,0x00,0x00)), // base QBrush(QColor(0x00,0x00,0x00)) // window )); setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); setReadOnly ( true ); QObject::connect(this, SIGNAL( is_active (QKeyEvent *) ), this, SLOT ( keyPressEvent (QKeyEvent *) ) ); QObject::connect(this, SIGNAL( is_active (QKeyEvent *) ), this, SLOT ( keyPressEvent (QKeyEvent *) ) ); }/* -------------------------------------------------------------------------- */ void QTerminal::keyPressEvent ( QKeyEvent * event ) { if (isActiveWindow()) { emit is_active ( event ); } }/* -------------------------------------------------------------------------- */
C++ (Qt)...
C++ (Qt)#include "terminal.h"/* -------------------------------------------------------------------------- */ QTerminal::QTerminal () :QPlainTextEdit() { setGeometry( 20, 20, 640, 480 ); setWordWrapMode( QTextOption::WrapAnywhere ); setPalette ( QPalette( QBrush(QColor(0x00,0x00,0x00)), // windowText QBrush(QColor(0xff,0xff,0xff)), // button QBrush(QColor(0xff,0xff,0xff)), // light QBrush(QColor(0xff,0xff,0xff)), // dark QBrush(QColor(0xff,0xff,0xff)), // mid QBrush(QColor(0xff,0xff,0xff)), // text QBrush(QColor(0xff,0xff,0xff)), // bright_text QBrush(QColor(0x00,0x00,0x00)), // base QBrush(QColor(0x00,0x00,0x00)) // window )); setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); setReadOnly ( true ); }/* -------------------------------------------------------------------------- */ void QTerminal::keyPressEvent ( QKeyEvent * event ) { // Do something }/* -------------------------------------------------------------------------- */
C++ (Qt)/* -------------------------------------------------------------------------- */ void MainWindow::readOut() { terminal->insertPlainText ( QString ( interpreter->readAllStandardOutput().data())); terminal->show(); }/* -------------------------------------------------------------------------- */ void MainWindow::run() { #ifdef _UNIX_ interpreter->start("./interpreter",QStringList() << *args << filename); #endif #ifdef _WINDOWS_ // ... #endif }/* -------------------------------------------------------------------------- */ void MainWindow::createConnections() { connect(interpreter, SIGNAL(readyReadStandardError()),this, SLOT(readErr())); connect(interpreter, SIGNAL(readyReadStandardOutput()),this, SLOT(readOut())); }/* -------------------------------------------------------------------------- */
C++ (Qt) void QTerminal::keyPressEvent ( QKeyEvent * event ) { // Do something }
C++ (Qt) void MainWindow::createConnections() { connect(interpreter, SIGNAL(readyReadStandardError()),this, SLOT(readErr())); connect(interpreter, SIGNAL(readyReadStandardOutput()),this, SLOT(readOut()));// садимся на finished connect(interpreter, SIGNAL(finished(int, QProcess::ExitCode)),this, SLOT(doneInter())); } void MainWindow::doneInter() {// уходим если до консоли дело не дошло if (terminal->isVisible()) QApplication::quit(); else terminal->mDoneFlag = true;} void QTerminal::keyPressEvent ( QKeyEvent * event ) {// уходим если нажат anyKey if (mDoneFlag) QApplication::quit(); }