c++ - QListWidget send doubleClicked signal with no items -


I have QListWidget on a dialog that I want to do something (for example, open a QFileDialog window) when a user Doubleclicks at QListWidget. Unfortunately, Zero is DoubleClimate (Constant QMD Index and Index) Fire only occurs when items in the list.

Is it possible to fire the signal in the widget whenever a double-click event has been received, anywhere within the widget? Or need a different approach?

You can do something like this in the list widget of the listwidget:

 < Code> listWidget-> Viewport () - & gt; InstallEventFilter (this); // "This" can be your window object   

Event filter method Check for event for the QEvent :: MouseButtonDblClick event:

  bool YourWindowClass :: eventFilter (QObject * obj), QEvent * event) {if (event-> Type () == QEvent :: MouseButtonDblClick) {QMouseEvent * mouseEvent = static_cast & lt; QMouseEvent * & gt; (Event); QDebug ("mouse double click% d% d", mouseEvent-> x (), mouseEvent-> y ()); Back true; } And {return QMainWindow :: eventFilter (obj, incident); }}   

I hope it helps.

Comments