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. Methods not recognized in QWidget implementation
Forum Update on Monday, May 27th 2025

Methods not recognized in QWidget implementation

Scheduled Pinned Locked Moved General and Desktop
5 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.
  • M Offline
    M Offline
    maartenverbandt
    wrote on last edited by
    #1

    Hi,

    I'm implementing a 'motorWidget', with the QWidget - class as a base. My widget can be displayed in my main-window, signals and slots are being recognized, but other custom methods e.g. 'refresh()', cannot be invoked from outside this class (I try calling it from my MainWindow class, but it isn't recognized as a member... ). QT designer reports: "class motorWidget has no member named 'refresh' ", although it is clearly defined in my code:

    @
    class motorWidget : public QWidget
    {
    Q_OBJECT

    public:
    explicit motorWidget(QWidget *parent = 0);
    ~motorWidget();
    void refresh();
    };
    @

    I checked if the header of this class is correctly defined, which seems to be the case. The class is being recognized, just the method seems to be missing somewhere.

    Is this some strange behavior of the QWidget class? Are other includes necessary to call public methods? I can solve my problems by calling my methods as a slot, but this is not the right way to go, so I'd rather have this mystery unravelled..

    Kind regards, Maarten

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Are you trying to use your widget inside Qt designer ?
      If yes then "here":http://qt-project.org/doc/qt-5/designer-creating-custom-widgets.html is info on how to create custom widget for Qt designer.

      If not then could you show how do you call this method?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maartenverbandt
        wrote on last edited by
        #3

        [quote author="andreyc" date="1406215534"]Are you trying to use your widget inside Qt designer ?
        If yes then "here":http://qt-project.org/doc/qt-5/designer-creating-custom-widgets.html is info on how to create custom widget for Qt designer.

        If not then could you show how do you call this method?[/quote]

        I implemented the QWidget-class to make my ‘motorWidget’ and used promote to make it appear in my gui, using indeed the QT designer.

        However, my intention is not to make a full new widget, but to just use the promote tool.

        When I try to call the widget from my main window, writing ‘ui->motorWidget1->refresh()’, the ui->motorWidget1 is really recognized as an instance of the motorWidget class, so its really strange. I’ve been looking at this for days and read many posts, such as QAccessibleWidgets (which I don’t think I need) and also the compilation as plugin (but QT was complainting about the ‘QT = designer’ so I stopped trying that).

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          I'm lost here :-)
          So you have

          created a widget

          added it to a window using "Promote" tool

          Now you try to call a method from your widget and getting an error. Is it right?

          What is the error?
          Could you post the minimal source code that produce an error .

          I don't think you need QAccessibleWidgets.
          What is 'QT = designer' error ?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maartenverbandt
            wrote on last edited by
            #5

            [quote author="andreyc" date="1406217861"]I'm lost here :-)
            So you have

            created a widget

            added it to a window using "Promote" tool

            Now you try to call a method from your widget and getting an error. Is it right?

            What is the error?
            Could you post the minimal source code that produce an error .

            I don't think you need QAccessibleWidgets.
            What is 'QT = designer' error ?

            [/quote]

            Hi,

            while setting up bare essentials code as you asked for, the problem didn't show. The only difference was that I first had a separate map for the motorWidget, the bare essentials were all located in the same folder. Maybe that was the problem, or other versions might have been shadowing my actual files. I don't know, but it seems to work right now. The only certainty is that I was looking too far for a solution. Thanks for making me realize it!

            thread solved ;)

            FWI: you correctly analyzed my setup ;)

            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