Below I have described the method to get active (focused) windows title using Qt in Linux systems (Such as Ubuntu, CentOS etc.) Basically you use xdotool with two parameters mentioned below to get the title of current window which has the focus.
Parameter 1 needs to be getwindowfocus and param 2 should be getwindowname. See below:
process.setArguments(QStringList() << “getwindowfocus” << “getwindowname”);
while(process.state() != QProcess::NotRunning)
Updated June 22, 2016
You might need to install xdotool if it doesn’t exist.