Mounting in user space is usually done with UDisks so you can just use udisksctl
to tell UDisks to mount a device in same way KDE does. (I'm not sure which service does this in KDE, in GNOME mounting is done by GVFS.)
udisksctl mount -b /dev/sdxY
udisksctl unmount -b /dev/sdxY
If you want to do everything manually, including detecting a new removable device was connected, you'll need to use either DBus to communicate with UDisks or libudisks. GVFS (and similar tools) watch for change event from UDisks and if the new block device contains a mountable filesystem, it will show some notification to user and then use UDisks mount function to mount the device.
If you are interested in doing something like that manually, I recommend these UDisks API examples from Canonical.