jamadagni
17th August 2012, 08:26
Hello. In my app I need to put three plain textboxes in three tabs. I'm trying to set the font of the textboxes via stylesheets but I seem to be doing something wrong -- can anyone help?
I looked up the documentation and it said that for QTextEdits I should set the style for QAbstractScrollArea but still it is not working. I'm using a QPlainTextEdit -- is that a problem?
The code is:
# include <QtGui/QApplication>
# include <QtGui/QPlainTextEdit>
# include <QtGui/QTabWidget>
int main ( int argc, char * argv [] )
{
QApplication app ( argc, argv ) ;
app . setStyleSheet ( "QAbstractScrollArea { font : \"DejaVu Sans\" }" ) ;
QPlainTextEdit * myInput = new QPlainTextEdit ;
QPlainTextEdit * stdOutput = new QPlainTextEdit ;
stdOutput -> setReadOnly ( true ) ;
QPlainTextEdit * stdError = new QPlainTextEdit ;
stdError -> setReadOnly ( true ) ;
QTabWidget * tabWidget = new QTabWidget ;
tabWidget -> addTab ( myInput, "Input" ) ;
tabWidget -> addTab ( stdOutput, "Output" ) ;
tabWidget -> addTab ( stdError, "Errors" ) ;
tabWidget -> show () ;
return app . exec () ;
}
Any help is appreciated. Thanks.
I looked up the documentation and it said that for QTextEdits I should set the style for QAbstractScrollArea but still it is not working. I'm using a QPlainTextEdit -- is that a problem?
The code is:
# include <QtGui/QApplication>
# include <QtGui/QPlainTextEdit>
# include <QtGui/QTabWidget>
int main ( int argc, char * argv [] )
{
QApplication app ( argc, argv ) ;
app . setStyleSheet ( "QAbstractScrollArea { font : \"DejaVu Sans\" }" ) ;
QPlainTextEdit * myInput = new QPlainTextEdit ;
QPlainTextEdit * stdOutput = new QPlainTextEdit ;
stdOutput -> setReadOnly ( true ) ;
QPlainTextEdit * stdError = new QPlainTextEdit ;
stdError -> setReadOnly ( true ) ;
QTabWidget * tabWidget = new QTabWidget ;
tabWidget -> addTab ( myInput, "Input" ) ;
tabWidget -> addTab ( stdOutput, "Output" ) ;
tabWidget -> addTab ( stdError, "Errors" ) ;
tabWidget -> show () ;
return app . exec () ;
}
Any help is appreciated. Thanks.