[SOLVED] No colored output on qtermwidget


(toby) #1

Hello all,

I’m having a problem with qtermwidget usage on qt creator; the qtermwidget that gets created does not have colored output (e.g. ls --color=auto or dmesg outputs plain white on black text). However, the prompt itself does seem to be colored (please see attached screenshot), and the widget does seem to respect the color scheme set by using setColorScheme(“Solarized”).

This is my setup code:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QFont font = QApplication::font();
    font.setFamily("Monospace");
    font.setPointSize(12);

    ui->console_widget->setTerminalFont(font);
    ui->console_widget->setColorScheme("Solarized");
    QObject::connect(ui->console_widget, SIGNAL(finished()), this, SLOT(close()));
}

And here is a screenshot comparing qterminal and my app with qtermwidget:

Could anyone please point me to relevant documentation or help me fix this problem?


(toby) #2

As luck would have it, I figured out the problem right after posting. For anyone else that may deal with this problem, you simply have to set your TERM variable to something sensible, for example konsole-256color. The full example of code may look like this (make sure to run the setenv function before setting up the ui)

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    setenv("TERM", "konsole-256color", 1);

    ui->setupUi(this);
    QFont font = QApplication::font();
    font.setFamily("Monospace");
    font.setPointSize(12);

    ui->console_widget->setTerminalFont(font);
    ui->console_widget->setColorScheme("Solarized");
    QObject::connect(ui->console_widget, SIGNAL(finished()), this, SLOT(close()));

}

(Alf Gaida) #3

Thats why this is implemented the Qterminal settings - no one should change sources for a simple and available setting.