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. Inserting a textbox in order to print information
Qt 6.11 is out! See what's new in the release blog

Inserting a textbox in order to print information

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 798 Views 1 Watching
  • 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.
  • J Offline
    J Offline
    john_hobbyist
    wrote on last edited by john_hobbyist
    #1

    Hello, I use this code:
    https://github.com/kklmn/OrthoView/blob/master/OrthoView.py
    I want to add a text box in order to print 4 lines of 30 characters (max) information each line. What method/function should I use for this? Where in the code should I focus?
    Thanks

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      You could use a QTextEdit since that can hold multiple text lines.

      You should create the QTextEdit in

      class OrthoView(qt.QWidget): (line 456) as that seems to be the main window holding all the other widgets.

      and maybe put it in around 464

      It seems to be using layout so I would add it to that layout and see where it ends up.

      layout = qt.QVBoxLayout(self)

      so that might be ok to add there.

      1 Reply Last reply
      2
      • J Offline
        J Offline
        john_hobbyist
        wrote on last edited by
        #3

        Thank you! In case I want only see text/information and not to be able to edit, what I use?

        mrjjM 1 Reply Last reply
        0
        • J john_hobbyist

          Thank you! In case I want only see text/information and not to be able to edit, what I use?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @john_hobbyist
          you can set TextEdit to ReadOnly.
          textedit.setReadOnly(true);

          1 Reply Last reply
          1
          • J Offline
            J Offline
            john_hobbyist
            wrote on last edited by
            #5

            I wrote:

            QTextEdit.setReadOnly(True);
            

            and I get this error:

            TypeError: setReadOnly(self, bool): first argument of unbound method must have type 'QTextEdit'
            

            I am trying to find the solution...Can you help?

            jsulmJ 1 Reply Last reply
            0
            • J john_hobbyist

              I wrote:

              QTextEdit.setReadOnly(True);
              

              and I get this error:

              TypeError: setReadOnly(self, bool): first argument of unbound method must have type 'QTextEdit'
              

              I am trying to find the solution...Can you help?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @john_hobbyist said in Inserting a textbox in order to print information:

              QTextEdit.setReadOnly(True);

              This does not make sense as setReadOnly is not a static method!
              You have to call it on your QTextEdit instance

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              3
              • J Offline
                J Offline
                john_hobbyist
                wrote on last edited by
                #7

                Sorry I do not understand...in which line should I insert it? Thanks

                mrjjM jsulmJ 2 Replies Last reply
                0
                • J john_hobbyist

                  Sorry I do not understand...in which line should I insert it? Thanks

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  @john_hobbyist
                  Hi
                  You should set it to the new QTextEdit you created.

                  name_of_your_variable.setReadOnly(True);

                  1 Reply Last reply
                  2
                  • J john_hobbyist

                    Sorry I do not understand...in which line should I insert it? Thanks

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by jsulm
                    #9

                    @john_hobbyist How is you QTextEdit instance called and where do you initialise it? I have no idea in which line you have to put that as I do not have your code. You just need to learn the absolute basics. And @mrjj even shows you how it should look like:

                    textedit.setReadOnly(true);
                    

                    where textedit is your QTextEdit instance.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    4
                    • J Offline
                      J Offline
                      john_hobbyist
                      wrote on last edited by john_hobbyist
                      #10
                      This post is deleted!
                      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