ArtDijk
ArtDijk

Reputation: 2017

Print results in Qt widget iso console

I am porting my console app to a QT gui. The app get data from a website and prints the rsult line by line in the console ( I use spyder). Each line are a few strings. Now I want to add a gui to the app so others can use the app as well. With QT designer I designed a nice gui. In a Main module I call the UI. Now I am trying to 'connect' my app to the gui. Since I am new to Qt (with PySide) I would like to build step by step and learn. Now I would like to show ('print' line by line) the results in a widget (e.g. QListView). Can you show me a example where ["this is line 1", "This is line two"] are show in two rows in a QT Widget. Thanks

Upvotes: 1

Views: 1010

Answers (1)

Eli Bendersky
Eli Bendersky

Reputation: 273796

I usually use QTextBrowser for a "logging" widget.

  1. Just create a QTextBrowser widget in your main window (i.e. self.log_widget = QTextBrowser())
  2. Add it to some layout to be visible and part of the window
  3. Log messages to it with the append method (which accepts a string). (i.e. self.log_widget.append('Hello'))

QTextBrowser is a powerful widget that can also accept HTML for formatted output.

Upvotes: 1

Related Questions