[Qt-interest] Call slot with default argument

Ian Thomson Ian.Thomson at iongeo.com
Wed Aug 5 13:33:26 CEST 2009


Hi,

Create wrapper slots, it is the most logical way. Qt even does this, as 
it has slots such as hide, show, setHidden, setVisible which all do 
similar things but handle the parameters differently.

Cheers,
Ian.

Justus Best wrote:
> Hi folks,
> 
> After some google-research I came across an old list entry
> http://lists.trolltech.com/qt-interest/2003-06/thread00306-0.html
> from 2003.
> My question is if there is an solution for that Problem by now. I can't
> find anything like that in the docs, but maybe I'am only looking for the
> wrong terms.
> 
> To give a minimal explanation of my Problem without reading the old list
> entry; I have two actions to sort a ListWidget ascending and descending
> and I don't want to maintain two differnent slots for this. So I have a
> slot like void sortList( Qt::SortOrder order ) which calls the Lists
> sortItems function. If I now try to connect the triggert signal of my
> action with this slot it fails because of unmatching parameters. It
> would be easy to call connect with
> action1...SLOT(sortList(Qt::AscendingOrder)) and action2 with
> SLOT(sortList(Qt::DescendingOrder)). But that isn't possible so I have
> to implement either two sort slots like sortListAsc and sortListDes, or
> if the sortList slot is more complex I have to add two wrapper slots to
> which call sortList with the right parameter.
> 
> My question is if there is a better solution for Problems like that.
> 
> Greets Justus
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list