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 Add Custom Class to Qt Designer/Edit Layout Outside of Qt Designer
Forum Updated to NodeBB v4.3 + New Features

How to Add Custom Class to Qt Designer/Edit Layout Outside of Qt Designer

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.7k Views
  • 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
    pistorinoj
    wrote on 15 Aug 2018, 18:48 last edited by
    #1

    I am using VS2015 C++ with Qt 5.11.0 and am using Qt Designer to layout the UI.

    In the UI, I have images that are displayed using QLabel. I want the user to be able to click on these images and different actions take place. It seems many people need this functionality and I followed some of the guides, such as: https://wiki.qt.io/Clickable_QLabel for adding it. I now have a new class called Clickablelabel that should do the trick.

    Now, how do I s substitute the new class for the existing Qlabels in Qt Designer?
    Alternatively, how do I edit the resulting ui files from Qt Designer to specify the new class?

    Thanks for any help.

    J 1 Reply Last reply 15 Aug 2018, 19:13
    1
    • P pistorinoj
      15 Aug 2018, 18:48

      I am using VS2015 C++ with Qt 5.11.0 and am using Qt Designer to layout the UI.

      In the UI, I have images that are displayed using QLabel. I want the user to be able to click on these images and different actions take place. It seems many people need this functionality and I followed some of the guides, such as: https://wiki.qt.io/Clickable_QLabel for adding it. I now have a new class called Clickablelabel that should do the trick.

      Now, how do I s substitute the new class for the existing Qlabels in Qt Designer?
      Alternatively, how do I edit the resulting ui files from Qt Designer to specify the new class?

      Thanks for any help.

      J Offline
      J Offline
      JonB
      wrote on 15 Aug 2018, 19:13 last edited by JonB
      #2

      @pistorinoj
      http://www.qtcentre.org/threads/37926-Subclassing-a-widget-created-in-Qt-Designer

      Code your derived class. Use the promotion feature in Designer to make the existing label an instance of your sub-class. The promotion dialog can be found on the right-click context menu in Designer.

      is from a while ago, but if it still works sounds like what you want...

      Also https://stackoverflow.com/questions/37454998/subclassing-widgets-in-qt-designer

      1 Reply Last reply
      2
      • P Offline
        P Offline
        pistorinoj
        wrote on 16 Aug 2018, 00:30 last edited by
        #3

        That appears to be it.
        Thanks

        1 Reply Last reply
        0

        1/3

        15 Aug 2018, 18:48

        • Login

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