Methods not recognized in QWidget implementation
-
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_OBJECTpublic:
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
-
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 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).
-
I'm lost here :-)
So you havecreated 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 author="andreyc" date="1406217861"]I'm lost here :-)
So you havecreated 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 ;)