Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Simple object to print output to a windowed screen
Forum Updated to NodeBB v4.3 + New Features

Simple object to print output to a windowed screen

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 578 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    Uberlinc
    wrote on last edited by
    #1

    Hi,

    So I'm learning C++ but also trying to jump across to GUI.
    I am hoping to do this using QT.

    So, whilst I am teaching myself C++ I would like to send what I would ordinarily send to a simple text/terminal output to an object within a GUI app.

    Can anyone suggest the right QT object to do this?
    QListWidget?
    QListView?

    Can anyone suggest a simple example to print, say, a list of numbers to this object?

    Many thanks.

    Uberlinc.

    JonBJ 1 Reply Last reply
    0
    • U Uberlinc

      Hi,

      So I'm learning C++ but also trying to jump across to GUI.
      I am hoping to do this using QT.

      So, whilst I am teaching myself C++ I would like to send what I would ordinarily send to a simple text/terminal output to an object within a GUI app.

      Can anyone suggest the right QT object to do this?
      QListWidget?
      QListView?

      Can anyone suggest a simple example to print, say, a list of numbers to this object?

      Many thanks.

      Uberlinc.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Uberlinc
      QListWidget/QListView would work. But they display a list of items, so you would (presumably) make each line of output be one item.

      To just display text like, say, a terminal/console would do, a QTextEdit displays multiple lines of text (without breaking it into a list). setAcceptRichText(false) would be suitable to ensure it only deals in plain text. In which case, a QPlainTextEdit would be even simpler. Both of these support scrolling as the content gets large, just like a terminal/soncole. You can also setReadOnly(true) to make it not allow the user to edit/type into it. Up to you whether you want this or a list of items.

      Whichever of these you use, QString QString::arg(int a) accepts an integer and returns it as a decimal string, suitable for putting it into a a list item or into a text edit widget. Or for QListWidget/QListView you can just put the numbers directly into the model and the view will show them as text for you.

      U 1 Reply Last reply
      1
      • JonBJ JonB

        @Uberlinc
        QListWidget/QListView would work. But they display a list of items, so you would (presumably) make each line of output be one item.

        To just display text like, say, a terminal/console would do, a QTextEdit displays multiple lines of text (without breaking it into a list). setAcceptRichText(false) would be suitable to ensure it only deals in plain text. In which case, a QPlainTextEdit would be even simpler. Both of these support scrolling as the content gets large, just like a terminal/soncole. You can also setReadOnly(true) to make it not allow the user to edit/type into it. Up to you whether you want this or a list of items.

        Whichever of these you use, QString QString::arg(int a) accepts an integer and returns it as a decimal string, suitable for putting it into a a list item or into a text edit widget. Or for QListWidget/QListView you can just put the numbers directly into the model and the view will show them as text for you.

        U Offline
        U Offline
        Uberlinc
        wrote on last edited by
        #3

        @JonB
        Okay, I'll give that a go.
        Thanks.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved