Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Wiki Discussion
  4. Class name mismatch when creating custom widget from QtDesigner
Forum Updated to NodeBB v4.3 + New Features

Class name mismatch when creating custom widget from QtDesigner

Scheduled Pinned Locked Moved Wiki Discussion
5 Posts 3 Posters 3.1k Views 2 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    I am coding a plugin for the Designer to add some widgets I have created. Before adding the code, I created the project through File -> New Project -> Other Project -> Qt Custom Designer Widget.

    If I add a custom widget that inherits straight from QWidget, i.e. QWidget -> MyWidget, it shows nicely in the Designer. But most of my widgets does not inherit directly from QWidget. Instead, they inherit from a custom base class that implements some shared functionality, e.g. QWidget -> MyScale -> MyCompass.

    When this happens, although MyCompass is shown correctly by the Designer, a dialog appears with the message: "Designer: A class name mismatch occurred when creating a widget using the custom widget factory registered for widgets of class MyCompass. It returned a widget of class MyScale.

    If I check the UI file generated by the Designer, it really registers the widget as MyScale, instead of MyCompass.

    How can I fix this?

    1 Reply Last reply
    1
    • apalomerA Offline
      apalomerA Offline
      apalomer
      wrote on last edited by
      #2

      I encountered the same error and found the solution in this other post. I was missing the Q_OBJECT macro in the class that I was creating the plugin for.

      Christian EhrlicherC 1 Reply Last reply
      2
      • apalomerA apalomer

        I encountered the same error and found the solution in this other post. I was missing the Q_OBJECT macro in the class that I was creating the plugin for.

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @apalomer Do you really think it's worth answering to a thread which is already 6 years old?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0
        • apalomerA Offline
          apalomerA Offline
          apalomer
          wrote on last edited by
          #4

          Yes, I do think so. This post was what I was finding as the first suggested link all the time regardless of how I formulated my question to google. I assumed many others may encounter this helpful, hence, I decided to post an answer. Moreover, the error has not changed through the years (the post where I found the answer is from August 2008), therefore, I find the question still valid and needed an answer.

          M 1 Reply Last reply
          2
          • apalomerA apalomer

            Yes, I do think so. This post was what I was finding as the first suggested link all the time regardless of how I formulated my question to google. I assumed many others may encounter this helpful, hence, I decided to post an answer. Moreover, the error has not changed through the years (the post where I found the answer is from August 2008), therefore, I find the question still valid and needed an answer.

            M Offline
            M Offline
            MaMingKun
            wrote on last edited by
            #5

            @apalomer Tankes for your anwser. you are a good man

            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