March 4, 2011

Luca Luca
Ant Farmer
589 posts

Bug in QTextEdit ?

 

Hi all,

I have this situations:

(1)

  1. te_anteprima = new QTextEdit();
  2. te_anteprima->setText(file_personalizzato_str);
  3. te_anteprima->show();

(2)

  1. te_anteprima = new QTextEdit(file_personalizzato_str);
  2. te_anteprima->show();

The QString file_personalizzato_str has some line that terminate with a new_line ( \n ) like this:

  1. [Generale]
  2. interfaccia_grafica=0
  3. connessione_a_star=%connessione_a_star%
  4. indirizzo_star=%indirizzo_star%
  5. utente_star=%utente_star%
  6. password_star=%password_star%
  7. ...
  8. ...

In the first case I see in the QTextEdit all the text with the right new line in the right place.

In the second case I see this:

  1. [Generale] interfaccia_grafica=0 connessione_a_star=%connessione_a_star% indirizzo_star=%indirizzo_star% utente_star=%utente_star% password_star=%password_star%

without new lines.

4 replies

March 4, 2011

Volker Volker
Robot Herder
5428 posts

Read the API docs:

QTextEdit::QTextEdit ( const QString & text, QWidget * parent = 0 )
Constructs a QTextEdit with parent parent. The text edit will display the text text. The text is interpreted as html.

March 4, 2011

Andre Andre
Area 51 Engineer
6031 posts

That is nice. And the problem is…?

Edit: indeed, it is all in the docs.
setText will try to guess if the contents are HTML or plain text. In this case, it guesses plain text (no HTML tags, so it is right about that). So, no bug in QTextEdit, the issue is with your documentation reading skills.

BTW: it is a bit rude to claim you’ve found a bug [catb.org], if you’re not really sure.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

March 4, 2011

Volker Volker
Robot Herder
5428 posts

Feeding plain text that will be interpreted as HTML will lead to loosing the line breaks, at least.

March 4, 2011

Luca Luca
Ant Farmer
589 posts

Volker wrote:
Read the API docs:

QTextEdit::QTextEdit ( const QString & text, QWidget * parent = 0 )
Constructs a QTextEdit with parent parent. The text edit will display the text text. The text is interpreted as html.

  1.  *The text is interpreted as html.*

I didn’t read this.

That’s why… Thanks!

 
  ‹‹ Audio Device Volume      QUdpSocket::readyRead() doesn’t emit after thread event loop restart ››

You must log in to post a reply. Not a member yet? Register here!