Reputation: 5466
I'm trying to get some attributes of a parent widget: SamplerModule
from its children: InstrumentSelector
.
From the InstrumentSelector
constructor, I run parent->metaObject()->className()
which gives me the right name (SamplerModule). So I'm sure that I'm in the right place to call one of my public method, for example getT()
defined as a public method in my SamplerModule
header and cpp file.
But, when I call this function, I'm getting this error:
\app\widgets\instrumentselector.cpp:23: erreur : 'class QWidget' has no member named 'getT' msgBox.setText(parent->getT());
So I think that's C++ and Qt basics but I'm still learning that.
Does someone have an idea ?
Thanks
Upvotes: 0
Views: 552
Reputation: 2444
Without seeing the code, it's hard to say for sure, but my guess is that you've defined "parent" as a "QWidget *", so the compiler has no idea that it's actually a base pointer to a SamplerModule. You need to either cast "parent" to a SamplerModule pointer, or declare it that way to start with. And yes, this is pure C++; it's not related to Qt.
Upvotes: 1