Search code examples
rubyqt4qtextedit

QtRuby: loading HTML file into QTextEdit


How do I load a custom HTML-file into QTextEdit while in runtime?


Solution

  • One very simple way. Be sure to check the documentation, look for error conditions, and what-not. Also, there might be a quicker way than reading it one line at a time.

    QFile file( file_name );
    QTextStream stream( &file );
    QString string;
    while( !stream.atEnd() )
    {
        stream >> string;
        ui_textEdit->insertHtml( string );
    }