You can write a plugin and override "q_view_main($q_view)" method. Something like this:
class qa_html_theme_layer extends qa_html_theme_base {
function q_view_main($q_view)
{
qa_html_theme_base::q_view_main($q_view);
// you can write your code here
}