The "no matching function" error arises because valueChanged() is a signal and its generated code is declared in the protected section of the class. If you want the value from the slider object directly then you want the value() function, not the signal indicating it has changed.
I assume that the "cannot convert 'int*' to 'gain*' in initialization" relates to this line:
Gain *volume = new volume;
Gain *volume = new volume;
To copy to clipboard, switch view to plain text mode
The LHS of this is type "Gain*". Since there's no class called "volume" the compiler has assumed an int so the RHS is type "int*". It's not entirely clear what you are trying to achieve here with this circular reference. If, as I suspect, you intended to create a new Gain object:
Gain *volume = new Gain;
Gain *volume = new Gain;
To copy to clipboard, switch view to plain text mode
then, had you succeeded, you would have always had value() == 50 from a slider that the user neither saw nor interacted with.
In a normal Qt program you would have a UI built containing widgets like your slider, ideally quite separate from the code that actually does substantial stuff in response. You can use Designer or hand code that UI. You would connect() the valueChanged() signal of your slider to a slot that reacts immediately to the changed value, for example pushing a new volume figure into your generator code. Assuming the tick() routine is part of the code you have pushed to another thread you could put the receiving slot in that QObject and store the current volume figure as a member variable in the generator thread.
Unless you want to do something like anda_skoa suggests to get a floating point or logarithmic slider then it strikes me that your Gain class could simply be a QSlider subclass, something like:
{
Q_OBJECT
public:
setRange(1, 100);
setValue(50);
}
};
class Gain: public QSlider
{
Q_OBJECT
public:
explicit Gain(QWidget *p = 0): QSlider(Qt::Horizontal, p) {
setRange(1, 100);
setValue(50);
}
};
To copy to clipboard, switch view to plain text mode
Do you want to allow a zero volume?
Bookmarks