PDA

View Full Version : Qt MousePressEvent on QTableWidget project



citix
16th January 2014, 10:24
I want to use MousePressEvent but I dont know how I need to create the files...(main.cpp, ProjectQt.cpp,ProjectQt.h)

Anyone help me to run MousePressEvent on a QTableWidget application. for example I found the event method but I dont know how I can run the method.


void mousePressEvent ( QMouseEvent * event ){
if(event->button() == Qt::LeftButton){

}
}

Anyone help me?

anda_skoa
16th January 2014, 11:45
Maybe it is even better if you ask about the thing you actually want to do.
There could be an easier way than to implement your own mouse handling, e.g. already existing signals.

Cheers,
_

citix
16th January 2014, 13:05
I can insert new Rows on a QTableWidget and can select items on that table. How can I unselect the selected items on the QTableWidget? I think I can do that action with mousePressedEvent. But I dont know how...

Added after 33 minutes:

I think the method can use like that but I still dont know X and Y . anyone know ?


connect(X,SIGNAL(Y),this,SLOT(mousePressEvent()));

anda_skoa
16th January 2014, 13:42
Have you tried a different selection mode?

If that does not work, what about connecting to the cellPressed() signal?

Cheers,
_