Results 1 to 6 of 6

Thread: how to set QLineEdit as not selectable?

  1. #1
    Join Date
    Jul 2010
    Posts
    17
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default how to set QLineEdit as not selectable?

    I'm using Qt Designer to create some forms and i have one QLineEdit field whiche i would like it to be not selectable.
    could anyone help me??
    thanks so much

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: how to set QLineEdit as not selectable?

    What do you mean by not selectable?

    Maybe you need some other widget (i saw in another topic, that you want a not editable QLineEdit) if you tell us what you are trying to achieve, maybe we can give better advices.

  3. The following user says thank you to Zlatomir for this useful post:

    pakine (25th August 2010)

  4. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to set QLineEdit as not selectable?

    If you mean text selection: reimp mouse press/move event and ignore it.

  5. The following user says thank you to Lykurg for this useful post:

    pakine (25th August 2010)

  6. #4
    Join Date
    Jul 2010
    Posts
    17
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to set QLineEdit as not selectable?

    yeah, i wanted to mean, disabling to select the text inside with the mouse. i should reimplement press/move events.
    thanks everybody

  7. #5
    Join Date
    Jul 2018
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to set QLineEdit as not selectable?

    I know that the thread is old but it still appears in Google.

    So, I used

    Qt Code:
    1. self.lineEdit.selectionChanged.connect(lambda: self.lineEdit.setSelection(0, 0))
    To copy to clipboard, switch view to plain text mode 

  8. #6
    Join Date
    Jun 2018
    Location
    Bangalore, India
    Posts
    6
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: how to set QLineEdit as not selectable?

    You can use a QLabel if you don't want people to edit your text. A line edit is used for taking input.
    If you want to it to be editable only at certain times, you can just update the label .

Similar Threads

  1. Replies: 1
    Last Post: 10th June 2010, 18:22
  2. Selectable header columns
    By eekhoorn12 in forum Qt Programming
    Replies: 0
    Last Post: 9th November 2009, 17:33
  3. How can I do, item is read only and not selectable ?
    By newermind in forum Qt Programming
    Replies: 11
    Last Post: 14th August 2009, 15:09
  4. QTableWidgetItem not selectable
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 14th February 2008, 19:15
  5. Replies: 3
    Last Post: 13th November 2007, 11:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.