Finding a menu Itemid in Joomla

My joomla component need to redirect in another page of same site but, that menu item not showing active, coz Itemid is not added in redirect url. I can’t just add the the itemid coz it will install in many site where itemid will not be the same. It’s maybe very simple for any joomla developer. I detect the page’s itemid by link attribute.

$menu = & JSite::getMenu();
$item = $menu->getItems('link', 'index.php?option=com_qc&view=qc',1);
echo $item->id;
and redirect to this link
index.php?option=com_qc&view=qc&Itemid='.$item->id