Results 1 to 2 of 2

Thread: geting QLabel text ontop of other QLabel displaying image

  1. #1
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question geting QLabel text ontop of other QLabel displaying image

    Its simple thing, but I can't figure out why the overlay text is not displayed ontop of another QLabel,

    here is the code I have that sets the overlay label that has text onto another existing label displaying image

    Qt Code:
    1. def _buildUi(self):
    2. self.label = QtGui.QLabel()
    3. self.overlayExifText = QtGui.QLabel(self.label)
    4. self.overlayExifText.setSizePolicy(QtGui.QSizePolicy.Ignored,
    5. QtGui.QSizePolicy.Ignored)
    6. self.overlayExifText.setStyleSheet("QLabel { color : blue; }")
    7. self.overlayExifText.setAlignment(QtCore.Qt.AlignTop)
    8. self.label.setBackgroundRole(QtGui.QPalette.Base)
    9. self.label.setSizePolicy(QtGui.QSizePolicy.Ignored,
    10. QtGui.QSizePolicy.Ignored)
    11. self.label.setAlignment(QtCore.Qt.AlignCenter)
    12. self.setCentralWidget(self.label)
    To copy to clipboard, switch view to plain text mode 

    here is the method that updates the text for current image

    Qt Code:
    1. def showImageByPath(self, path):
    2. if path:
    3. self.overlayExifText.setText("\n".join(list(utils.getExifData((path)))))
    4. image = QtGui.QImage(path)
    5. pp = QtGui.QPixmap.fromImage(image)
    6. self.label.setPixmap(pp.scaled(
    7. self.label.size(),
    8. QtCore.Qt.KeepAspectRatio,
    9. QtCore.Qt.SmoothTransformation))
    To copy to clipboard, switch view to plain text mode 

    only first letter of the text gets visible. also I tried setting some default text then it displays text with black background then that area also shows the little bit more of data the is yielded by the second method above. For full code have a look at this repo

  2. The following 3 users say thank you to krystosan for this useful post:

    ebirdseystew (18th December 2013)

  3. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: geting QLabel text ontop of other QLabel displaying image

    Your container label doesn't have a layout. So its child label doesn't get resized correctly when its content changes

    Cheers,
    _

  4. The following 3 users say thank you to anda_skoa for this useful post:

    ebirdseystew (18th December 2013)

Similar Threads

  1. Qlabel not displaying images other than development machine
    By arunkumaraymuo1 in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2012, 14:52
  2. Problem with displaying image using Qlabel
    By deck99 in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2011, 00:23
  3. Replies: 1
    Last Post: 29th September 2009, 19:44
  4. Replies: 6
    Last Post: 21st September 2009, 10:55
  5. Replies: 1
    Last Post: 2nd August 2008, 15:46

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.