Results 1 to 3 of 3

Thread: Change QLabel to QLineEdit when mousePressEvent happens

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    8
    Thanked 133 Times in 128 Posts

    Default Re: Change QLabel to QLineEdit when mousePressEvent happens

    just show and hide the label/lineedit on mouseclickevent and editingfinishied signals respectively

  2. #2
    Join Date
    Jul 2009
    Posts
    14
    Qt products
    Platforms
    MacOS X Windows
    Thanks
    1

    Default Re: Change QLabel to QLineEdit when mousePressEvent happens

    Hi MrDeath, thank you for your reply.

    yes it works!!
    thank you so much!
    here is my code for interests

    Qt Code:
    1. class nameDisplay(QtGui.QLabel):
    2. def __init__(self,buddyList,parent=None):
    3. QtGui.QLabel.__init__(self, parent)
    4. self.buddyList = buddyList
    5. def mousePressEvent(self, event):
    6. print 'mousePressEvent'
    7. self.buddyList.username.hide()
    8. self.buddyList.usernameInput = QtGui.QLineEdit(self.buddyList)
    9. self.buddyList.usernameInput.setGeometry(QtCore.QRect(120, 10, 121, 20))
    10. self.buddyList.usernameInput.setText(self.buddyList.username.text())
    11. self.buddyList.usernameInput.selectAll()
    12. self.buddyList.usernameInput.show()
    13. self.connect(self.buddyList.usernameInput,QtCore.SIGNAL("returnPressed()"),self.editingFinish)
    14. def editingFinish(self):
    15. self.buddyList.usernameInput.hide()
    16. self.buddyList.username.show()
    17. self.buddyList.username.setText(self.buddyList.usernameInput.text())
    To copy to clipboard, switch view to plain text mode 

    regards

Similar Threads

  1. Replies: 5
    Last Post: 10th July 2009, 13:11
  2. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 16:13
  3. Change color of a link in QLabel using Style Sheets?
    By codeslicer in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2008, 12:00
  4. Connect QLabel and QLineEdit
    By abbapatris in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2008, 20:00
  5. Replies: 1
    Last Post: 26th November 2006, 10:32

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.