Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Qlineedit: uneditable text + editable text

Qlineedit: uneditable text + editable text

Scheduled Pinned Locked Moved Solved Qt for Python
7 Posts 2 Posters 1.3k 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.
  • B Offline
    B Offline
    blossomsg
    wrote on 29 Oct 2020, 08:01 last edited by
    #1

    Hello guys,
    I hope all of you are doing great.

    In qlineedit i need a way to keep a
    static text in the beginning and after those characters i want to mention any text(editable text)

    example
    edit_point_qlineedit_2.jpg edit_point_qlineedit.jpg

    above example is from qt designer
    i disabled frames from lineedit and label
    and placed it besides each other

    But i am assuming there must be some effective way as well

    Thanks

    J 1 Reply Last reply 29 Oct 2020, 08:10
    0
    • B blossomsg
      29 Oct 2020, 08:01

      Hello guys,
      I hope all of you are doing great.

      In qlineedit i need a way to keep a
      static text in the beginning and after those characters i want to mention any text(editable text)

      example
      edit_point_qlineedit_2.jpg edit_point_qlineedit.jpg

      above example is from qt designer
      i disabled frames from lineedit and label
      and placed it besides each other

      But i am assuming there must be some effective way as well

      Thanks

      J Offline
      J Offline
      JonB
      wrote on 29 Oct 2020, 08:10 last edited by JonB
      #2

      @blossomsg
      If your text is supposed to be a separate label at the left that would be easiest.

      If you really mean you want text to be inside the QLineEdit and "stick" there, you would have to subclass QLineEdit and do whatever to keep it there while the user edits, e.g. never let the cursor go left into it, or something similar.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blossomsg
        wrote on 29 Oct 2020, 11:01 last edited by
        #3

        Hello @JonB
        Thank you for the reply,
        i have never tried subclassing specifically qlineedit, combobox or anything to modify
        an example would be a great help, or if there is any page to go through, can you please share

        J 1 Reply Last reply 29 Oct 2020, 11:11
        0
        • B blossomsg
          29 Oct 2020, 11:01

          Hello @JonB
          Thank you for the reply,
          i have never tried subclassing specifically qlineedit, combobox or anything to modify
          an example would be a great help, or if there is any page to go through, can you please share

          J Offline
          J Offline
          JonB
          wrote on 29 Oct 2020, 11:11 last edited by JonB
          #4

          @blossomsg
          Have you subclassed anything in C++? That is needed in much Qt stuff.

          A couple of the simplest examples I could spot are:
          https://stackoverflow.com/questions/38958873/a-simple-subclass-of-qwidget-doesnt-work-as-a-qwidget
          https://stackoverflow.com/questions/37454998/subclassing-widgets-in-qt-designer

          Don't worry about the problem the posters there are asking about, just look at the few lines in their code which do the subclassing.

          But really you just need to know about C++ subclassing, and that's beyond the scope of a reply in this forum :)

          1 Reply Last reply
          2
          • B Offline
            B Offline
            blossomsg
            wrote on 29 Oct 2020, 12:37 last edited by
            #5

            Hey @JonB
            Sorry for not informing earlier but i am working in pyside2(python3.8)

            J 1 Reply Last reply 29 Oct 2020, 12:53
            0
            • B blossomsg
              29 Oct 2020, 12:37

              Hey @JonB
              Sorry for not informing earlier but i am working in pyside2(python3.8)

              J Offline
              J Offline
              JonB
              wrote on 29 Oct 2020, 12:53 last edited by
              #6

              @blossomsg
              So you need to do subclassing in Python! It's the same principle, different syntax. You can Google for something like python qt widget subclass if you want to find Qt examples.

              1 Reply Last reply
              1
              • B Offline
                B Offline
                blossomsg
                wrote on 17 Jan 2021, 07:50 last edited by
                #7

                I avoided the subclassing as it did not give me desired output
                went with simple approach
                closing ticket

                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