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. [SOLVED] PySide : Failing to create specialized label

[SOLVED] PySide : Failing to create specialized label

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 965 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.
  • B Offline
    B Offline
    blueblood
    wrote on last edited by
    #1

    Hello there.

    In my user interface i'll be having quite a number of labels and i simply don't like the default font size, so i thought about creating a specialized label.

    Here's the code:

    @
    from PySide import QtGui
    class MyLabel(QtGui.QLabel):
    def init(self, labeltext):
    super(MyLabel, self).init(labeltext)
    font = QtGui.QFont()
    font.setPointSize(12)
    self.setFont(font)
    @

    and that's it.When I try to create an instance from this label, the interpreter just restarts (or in case of the Python commandline, the window closes).

    Am I doing something wrong?

    Thanks

    1 Reply Last reply
    0
    • B Offline
      B Offline
      blueblood
      wrote on last edited by
      #2

      Ok.I just didn't create a main application before creating a label instance:

      @
      import sys
      app = QtGui.QApplication(sys.argv)

      label = MyLabel('Hello Label!')

      label.show()
      @

      works nicely!

      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