PDA

View Full Version : Strange insertion behavior to QPlainTextEdit when using stylesheet



BasementCat
17th November 2010, 01:29
I am noticing some strange text insertion behavior to a QPlainTextEdit widget when using a stylesheet. I'd like to use a 'fixed' font in my stylesheet. when i do this, i see that the text i want inserted 'inject' is actually missing the 'nj' characters so i end up with 'i ect' in the widget. when i use 'Courier' instead of 'fixed' font-family in the stylesheet, all is well. could it be due to my font server or problem with my environment? i don't have ready access to test on another machine outside of my environment.

here's the code:


#include <QtCore>
#include <QtGui>

//-----------------------------------------------------------
// main
//-----------------------------------------------------------
int main (int argc, char* argv[]) {

QApplication app(argc, argv);

QMainWindow *main_window = new QMainWindow();
main_window->setGeometry(100,100,800,600);

// if you use font-family: "Courier", output looks fine. only problematic
// with "fixed"
//
app.setStyleSheet(
"QPlainTextEdit{ font-family: \"fixed\"; }"
);

QWidget *main = new QWidget();

QPlainTextEdit *text = new QPlainTextEdit();

QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(text);
main->setLayout(layout);

main_window->setCentralWidget(main);

// this should show 'i ect' in the text window
// NOTE: 'nj' chars are simply not printed
//
text->appendPlainText("inject");

main_window->show();

return app.exec();

}

thoughts? sorry in advance if this is basic question.