Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QPalette QApplication::palette ( const QWidget widget  )  [static]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. If a widget is passed, the default palette for the widget's class is returned. This may or may not be the application palette. In most cases there isn't a special palette for certain types of widgets, but one notable exception is the popup menu under Windows, if the user has defined a special background color for menus in the display settings.

See also:
setPalette(), QWidget::palette()

Definition at line 1499 of file qapplication.cpp.

References QHash< Key, T >::constBegin(), QHash< Key, T >::constEnd(), QHash< Key, T >::constFind(), QObject::inherits(), QHash< Key, T >::key(), palette(), QHash< Key, T >::size(), and QHash< Key, T >::value().

{
    PaletteHash *hash = app_palettes();
    if (w && hash && hash->size()) {
        QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(w->metaObject()->className());
        if (it != hash->constEnd())
            return *it;
        for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
            if (w->inherits(it.key()))
                return it.value();
        }
    }
    return palette();
}


Generated by  Doxygen 1.6.0   Back to index