All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Static Public Member Functions
QGpGuiTools::Cast Class Reference

#include <Cast.h>

List of all members.

Static Public Member Functions

template<typename TIn , typename TOut >
static TOut getFirst (QList< TIn > list)
template<typename T >
static T getTab (QTabWidget *tab, QString tabName)

Member Function Documentation

template<typename TIn , typename TOut >
TOut QGpGuiTools::Cast::getFirst ( QList< TIn >  list) [static]

Return the first element if list which can be casted to TOut type. List is of type QList<TIn>.

TIn and TOut are pointers to classes that inherit QObject.

{
  typedef typename QList<TIn>::iterator ListIterator;
  ListIterator it;
  TOut obj;
  for(it=list.begin();it!=list.end();++it) {
    obj=qobject_cast<TOut>( *it);
    if(obj) return obj;
  }
  return 0;
}
template<typename T >
T QGpGuiTools::Cast::getTab ( QTabWidget *  tab,
QString  tabName 
) [static]

Return the widget named tabName and that inherits T. The search is performed in the list of page of a QTabWidget

References w.

{
  T w=0;
  for(int i=tab->count() - 1; w==0 && i >= 0 ;i-- ) {
    w=qobject_cast<T>(tab ->widget(i) );
    if(w && w->objectName()!=tabName) w=0;
  }
  return w;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines