steg90
23rd May 2007, 12:44
Hi,
I have a TableView which is linked to a model. I have overriden viewportEvent in my table view ( for various reasons ) and have added the following piece of code to it :
if( event->type() == QEvent::MouseButtonPress )
{
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
QPoint index = helpEvent->pos();
QModelIndex item = indexAt( index );
if( item.isValid() )
{
CDADcb::CSignal* pSignals;
pSignals = (CDADcb::CSignal*)theApp->m_dcb.GetSignalList()->at(item.row());
}
}
For some reason, I have to click far left of each cell in my table for the model index to be valid, any reason for this or is the above wrong?! Maybe it would be best to emit a signal from my model when item is clicked?
Regards,
Steve
I have a TableView which is linked to a model. I have overriden viewportEvent in my table view ( for various reasons ) and have added the following piece of code to it :
if( event->type() == QEvent::MouseButtonPress )
{
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
QPoint index = helpEvent->pos();
QModelIndex item = indexAt( index );
if( item.isValid() )
{
CDADcb::CSignal* pSignals;
pSignals = (CDADcb::CSignal*)theApp->m_dcb.GetSignalList()->at(item.row());
}
}
For some reason, I have to click far left of each cell in my table for the model index to be valid, any reason for this or is the above wrong?! Maybe it would be best to emit a signal from my model when item is clicked?
Regards,
Steve