AFAIK using libnotify is the way to go if you don't want to use this method, which I found after doing some network searching:
system("notify-send 'The Message Title' 'Your Message Text' '-t' 5000");
the -t option is for notification timeout.
you can read the "Report" message:
Ubuntu user guide: using notify-send
, Qt KDE, GNOME
, :), ; .