Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, April 2008
QTextEdit and <hr> html tag.


Message 1 in thread

Hi, 


While playing around with a QTextEdit to append data to, and some HTML tags, I noticed a strange behaviour when adding a <hr>. When I read that some basic HTML tags could be used I thought that <hr> might be a nice separator between updates.
But when I do a first separation with a <hr> and then add extra updates with append(), every line gets a <hr> in between, unlike the expectation that it would draw a line at only the next call of the <hr>.

Here's a very basic example of what I mean.

#include <QApplication>
#include <QTextEdit>
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QTextEdit * area = new QTextEdit();
    area->append("This is a test");
    area->append("<HR>");
    //area->append("------");
    for ( int i = 0 ; i <= 5; i++)
    {
	area->append("TEST");
    }
    area->append("------");
    area->show();
    return app.exec();
}

Using QT 4.3.3 on Linux, I get a <hr> being drawn between every "TEST" and each following use of append().

Any ideas?


Best regards,

Christopher Ranschaert.

--
 [ signature omitted ] 

Message 2 in thread

Christopher Ranschaert wrote:

> Hi,
> 
> 
> While playing around with a QTextEdit to append data to, and some HTML
> tags, I noticed a strange behaviour when adding a <hr>. When I read that
> some basic HTML tags could be used I thought that <hr> might be a nice
> separator between updates. But when I do a first separation with a <hr>
> and then add extra updates with append(), every line gets a <hr> in
> between, unlike the expectation that it would draw a line at only the next
> call of the <hr>.
> 

It's probably related to bug169474, which is all about wierd behaviour of
the hr tag.

http://trolltech.com/developer/task-tracker/index_html?id=169474&method=entry

Email the testcase to qt-bugs@xxxxxxxxxxxxxx

My workaround for the bug was to surround the hr in a table, though it's not
perfect.

#include <QApplication>
#include <QTextEdit>
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QTextEdit * area = new QTextEdit();
    area->append("This is a test");
    area->append("<table width=\"100%\"><tr><td><hr /></td></tr></table>");
    //area->append("------");
    for ( int i = 0 ; i <= 5; i++)
    {
        area->append("TEST");
    }
    area->append("------");
    area->show();
    return app.exec();
}

Best Regards,

Steve.

--
 [ signature omitted ]