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, 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: Event filter method I hope it helps. Zero is DoubleClimate (Constant QMD Index and Index) Fire only occurs when items in the list.
< Code> listWidget-> Viewport () - & gt; InstallEventFilter (this); // "This" can be your window object
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); }}
Comments
Post a Comment