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. How to get QLineEdit to elide and align left?

How to get QLineEdit to elide and align left?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 3.7k 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.
  • P Offline
    P Offline
    patrickkidd
    wrote on last edited by patrickkidd
    #1

    QLineEdit seems to align long content to the right while truncating the content on the left. Seems as though it should be the reverse. the default alignment is already Qt.AlignLeft | Qt.AlignVCenter. How can I make it so the far left characters are already shown?

    0_1560582814619_Untitled 2.png

    Thanks!

    https://alaskafamilysystems.com/

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Afaics it depends on the cursor position

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • P Offline
        P Offline
        patrickkidd
        wrote on last edited by
        #3

        @Christian-Ehrlicher said in How to get QLineEdit to elide and align left?:

        Afaics it depends on the cursor position

        I tried lineEdit->home(true) but there was no effect.

        https://alaskafamilysystems.com/

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by Christian Ehrlicher
          #4

          It's working fine for me here:

          0_1560585012705_Screenshot_1.png

          Are you sure you call it after your set the text?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          P 1 Reply Last reply
          3
          • Christian EhrlicherC Christian Ehrlicher

            It's working fine for me here:

            0_1560585012705_Screenshot_1.png

            Are you sure you call it after your set the text?

            P Offline
            P Offline
            patrickkidd
            wrote on last edited by
            #5

            @Christian-Ehrlicher said in How to get QLineEdit to elide and align left?:

            It's working fine for me here:

            0_1560585012705_Screenshot_1.png

            Are you sure you call it after your set the text?

            I can verify that setting the cursor position works using the following simple example, which means that my problem is somewhere else in my code:

            def test_QLineEdit_alignment():
            
                app = QApplication(sys.argv)
            
                w = QLineEdit()
                w.setReadOnly(True)
                w.resize(50, 20)
                w.setText('1234567890 1234567890')
                w.setCursorPosition(0)
                w.show()
                app.exec()
            
            
            test_QLineEdit_alignment()
            

            Thanks!

            https://alaskafamilysystems.com/

            1 Reply Last reply
            3

            • Login

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