• Antelope Release 5.9 Mac OS X 10.13.2 2019-05-01

 

NAME

BQCommandConsole - BRTT Qt graphics extension for making a user typein command console

SYNOPSIS


$(QTNATIVELIBS) -lbqplot_native -lbanner -lbrttutil -lbumapdata $(DBLIBS) $(TRLIBS)

#include "BQ.h"

DESCRIPTION

BQCommandConsole objects are used to provide a user interface for typing commands.

This class inherits the BQConfigure class which is itself a subclass of the BUConfigure class with extensions to process Qt colors and fonts. The Qconfigure methods are implemented in the BUConfigure parent (see BUConfigure(3)).

INHERITS FROM

QTextEdit, BQConfigure

CONSTRUCTOR

BQCommandConsole(QWidget *parent);

Where "parent" is the QWidget parent for this object.

METHODS INHERITED FROM BQConfigure

BQCommandConsole METHODS

OBJECT CONFIGURATION PARAMETERS

EXAMPLE

Following is a simple c++ example.


#include "BQ.h"

int
main (int argc, char **argv)

{
	QApplication qapp(argc, argv);

	qapp.setApplicationName("bqplot_test_commandconsole");

	QWidget *widget = new QWidget();
	widget->setWindowTitle("bqplot_test_commandconsole");
	widget->show();
	widget->resize (500, 200);

	QGridLayout *layout = new QGridLayout (widget);
	layout->setSpacing (0);
	layout->setContentsMargins (0, 0, 0, 0);
	widget->setLayout (layout);

	BQCommandConsole *cc = new BQCommandConsole (widget);

	cc->setCommandCallback ( [cc](QString command, BQ_ClientData client_data) {
		char syscommand[512];
		sprintf (syscommand, "(%s >test.stdout) >&test.stderr\n", command.BQ_QString2char);
		system (syscommand);
		QFile stdout("test.stdout");
		QFile stderr("test.stderr");
		QString line;
		if (stdout.open(QIODevice::ReadOnly | QIODevice::Text)) {
			while (!stdout.atEnd()) {
        		line = QString::fromLatin1(stdout.readLine().data());
        		cc->printLineOutput ("", line, 0, 0);
    		}
			stdout.close();
			system ("rm -f test.stdout");
		}
		if (stderr.open(QIODevice::ReadOnly | QIODevice::Text)) {
			while (!stderr.atEnd()) {
        		line = QString::fromLatin1(stderr.readLine().data());
        		cc->printLineOutput ("", line, 1, 0);
    		}
			stderr.close();
			system ("rm -f test.stderr");
		}
		line.clear();
       	cc->printLineOutput ("", line, 0, 1);
	} );

	layout->addWidget (cc, 0, 0, 1, 1);

	qapp.exec();

	exit (0);
}



SEE ALSO

bqplot(3), BQConfigure(3)

AUTHOR

Danny Harvey, BRTT