[Qt-interest] Overwriting public slots and qobject_cast
Álvaro Morais
alvarommorais at gmail.com
Wed Jun 3 18:39:27 CEST 2009
Hi.
I want to make a custom progressBar that changes color with
percentage. For example 25% will give a highlight red, 50% Yellow,
etc...
It will also automatically give the password entropy of a QString, so
the setValue SLOT will become private, since there is no need to
change it from outside.
I'm using the promote to custom widget on the QtDesigner.
My question is: What is the best way of overwriting the public slots?
is it safe to do this:
class PasswordQuality : public QProgressBar
{
...
private slots:
virtual void setValue ( int value ) {
qobject_cast<QProgressBar*>(this)->setValue(value);
... //code to change the palette.
}
};
Am I using qobjet_cast the right way?
Thanks in advance.
--
Neither Emacs or Vi are my primary editors...
..and I'm not ashamed!!!
More information about the Qt-interest-old
mailing list