KUserGroup Class

Represents a group on your system. More...

Header: #include <KUser>
CMake: find_package(KF6 REQUIRED COMPONENTS CoreAddons)
target_link_libraries(mytarget PRIVATE KF6::CoreAddons)

Public Functions

KUserGroup(KGroupId gid)
KUserGroup(KUser::UIDMode mode = KUser::UseEffectiveUID)
KUserGroup(K_GID gid)
KUserGroup(const QString &name)
KUserGroup(const char *name)
KUserGroup(const group *g)
KUserGroup(const KUserGroup &group)
~KUserGroup()
KGroupId groupId() const
bool isValid() const
QString name() const
QStringList userNames(uint maxCount = KCOREADDONS_UINT_MAX) const
QList<KUser> users(uint maxCount = KCOREADDONS_UINT_MAX) const
bool operator!=(const KUserGroup &group) const
KUserGroup &operator=(const KUserGroup &group)
bool operator==(const KUserGroup &group) const

Static Public Members

QStringList allGroupNames(uint maxCount = KCOREADDONS_UINT_MAX)
QList<KUserGroup> allGroups(uint maxCount = KCOREADDONS_UINT_MAX)

Detailed Description

This class represents a group on your system. You can either get information about the group of the current user, of fetch information about a group on the system. Instances of this class will be explicitly shared, so copying objects is very cheap and you can safely pass objects by value.

Member Function Documentation

[explicit] KUserGroup::KUserGroup(KGroupId gid)

Creates an object for the group with the given group id. If the KGroupId object is invalid this one will be, too.

gid the group id

[explicit] KUserGroup::KUserGroup(KUser::UIDMode mode = KUser::UseEffectiveUID)

Create an object from the group of the current user.

mode if #KUser::UseEffectiveUID is passed the effective user will be used. If #KUser::UseRealUserID is passed the real user will be used. The real UID will be different than the effective UID in setuid programs; in such a case use the effective UID for checking permissions, and the real UID for displaying information about the group associated with the user.

[explicit] KUserGroup::KUserGroup(K_GID gid)

Create an object from a group id. If the group does not exist, isValid() will return false.

gid the group id

[explicit] KUserGroup::KUserGroup(const QString &name)

Create an object from a group name. If the group does not exist, isValid() will return false.

name the name of the group

[explicit] KUserGroup::KUserGroup(const char *name)

Create an object from a group name. If the group does not exist, isValid() will return false.

name the name of the group

[explicit] KUserGroup::KUserGroup(const group *g)

Creates an object from a group structure. If the pointer is null, isValid() will return false.

g the group structure to create the group from.

KUserGroup::KUserGroup(const KUserGroup &group)

Creates a new KUserGroup instance from another KUserGroup object

group the KUserGroup to copy

[noexcept] KUserGroup::~KUserGroup()

Destructor.

[static] QStringList KUserGroup::allGroupNames(uint maxCount = KCOREADDONS_UINT_MAX)

maxCount the maximum number of groups to return

Returns a list of all group names on this system

[static] QList<KUserGroup> KUserGroup::allGroups(uint maxCount = KCOREADDONS_UINT_MAX)

maxCount the maximum number of groups to return

Returns a list of all groups on this system

KGroupId KUserGroup::groupId() const

Returns the native group id of the user.

bool KUserGroup::isValid() const

Returns whether the group is valid. A KUserGroup object can be invalid if it is created with a non-existing gid or name. Returns true if the group is valid

QString KUserGroup::name() const

The name of the group. Returns the name of the group

QStringList KUserGroup::userNames(uint maxCount = KCOREADDONS_UINT_MAX) const

maxCount the maximum number of groups to return

Returns a list of all user login names of the group

QList<KUser> KUserGroup::users(uint maxCount = KCOREADDONS_UINT_MAX) const

maxCount the maximum number of users to return

Returns a list of all users of the group

bool KUserGroup::operator!=(const KUserGroup &group) const

Two KUserGroup objects are not equal if their gid()s are not identical. Invalid groups always compare unequal. Returns true if the groups are not identical

KUserGroup &KUserGroup::operator=(const KUserGroup &group)

Copies a group

group the group that should be copied

Returns this group

bool KUserGroup::operator==(const KUserGroup &group) const

Returns true if this group's gid() is identical to the one from group. Invalid groups never compare equal.