Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, May 2008
Extending QWhatsThis


Message 1 in thread

	Hello all,

	I'm porting Qt3 code to Qt4 and I'm stucked in a problem with QWhatsThis.
	My legacy code extends QWhatsThis this way:

   class HelpWhatsThis : public QWhatsThis {
   public:

     HelpWhatsThis(QWidget * parent, QGAppDialogMediator * med) :
	QWhatsThis(parent), _med(med);

     // This overloaded method allows the user to request a more
     // extended help on the parameter. Clicking on an hyperlink in
     // the help message will notify the mediator that further help has
     // been requested. The target of the hyperlink is passed to the
     // mediator that will update the dialog accordingly.
     bool clicked(const QString& href);

   private:
     QGAppDialogMediator * _med;

	Since QWhatsThis has his constructor private in Qt4, I'm unable to keep 
the extended class.

	My only ideia is to forget this extension creating a ordinary 
QWhatsThis and a QAction that will deal with the communication my former 
extended class do.

	By the way, it is a Mediator Pattern implementation.

	Thanks in advance,

	
-- 
 [ signature omitted ] 

Message 2 in thread

Hi,

"Vitor Vasconcelos Araujo Silva" <Vitor.Vasconcelos@xxxxxxxx> wrote in 
message news:483AC35B.1000404@xxxxxxxxxxx
> Hello all,
>
> I'm porting Qt3 code to Qt4 and I'm stucked in a problem with QWhatsThis.
> My legacy code extends QWhatsThis this way:
>
>   class HelpWhatsThis : public QWhatsThis {
>   public:
>
>     HelpWhatsThis(QWidget * parent, QGAppDialogMediator * med) :
> QWhatsThis(parent), _med(med);
>
>     // This overloaded method allows the user to request a more
>     // extended help on the parameter. Clicking on an hyperlink in
>     // the help message will notify the mediator that further help has
>     // been requested. The target of the hyperlink is passed to the
>     // mediator that will update the dialog accordingly.
>     bool clicked(const QString& href);
>
>   private:
>     QGAppDialogMediator * _med;
>
> Since QWhatsThis has his constructor private in Qt4, I'm unable to keep 
> the extended class.
>
> My only ideia is to forget this extension creating a ordinary QWhatsThis 
> and a QAction that will deal with the communication my former extended 
> class do.
>
> By the way, it is a Mediator Pattern implementation.

You could also look into using the event filter system that is available in 
Qt. Since clicking on a hyperlink in a what's this will result in an 
QWhatsThisClickedEvent on the widget the what's this is created on, you 
should be able to filter those events and handle them in your Mediator 
object as usual. I think I would just iterate over the child widgets of your 
dialog after construction to install the event filter, but that depends on 
how your application is build exactly.

André 

--
 [ signature omitted ]