qt - QListView with custom item => mouse events are propagated -


I would like to use QListView with a custom widget that includes QSlider and QSpinBox widget. I will give QListView a new custom item rep Succeeded in creating a custom widget that displays but the icons are not promoted in the event custom widget.

It is not possible to slide QSlider or change the value of QSpinBox. The user can not interact with the item.

I'm new to Qt and I think custom widgets do not have children in the catalog view. I tried to add visits to the list view (in item delegate controller), but that does not work.

I also tried to broadcast an item representative event in widgets using QWidget :: event ()

Is there any idea?

This is a custom widget:

< P> This QListView is displaying a custom widget:

< P> Here is the code of my custom item delegation:

  #include & lt; QPainter & gt; #include "layeritemwidgetdelegate.h" # / include "../../libs/debug/debug.h" Leyritm Viddet Diliget :: Layer Itam Videt Dieleget (QObject * ptParent): QItemDelegate (ptParent), m_ptItemWidget (New LayerItemWidget ( }) {} LayerItemWidgetDelegate:: ~ LayerItemWidgetDelegate () {Delete} m_ptItemWidget; } Void layer Aitam Videt Diliget :: Paint (Kyupenetr * Piteepianetr, Const Kyuleovovwuitm and amp; Topshn, Const Kyuemdel Index and Tindeks) Const {Kyubet tablet; // Change the size of the item widget m_ptItemWidget-> Resize (tOption.rect.size ()); // Change the background color of the widget if it is selected (QStyle :: State_Selected == (toption.state and QStyle :: State_Selected)) tPalette.setBrush (QPalette :: window, QBrush (QColor (Qt :: lightGray)) ; Else tPalette.setBrush (QPalette :: window, QBrush (QColor (Qt :: transparent)); M_ptItemWidget- & gt; Setpeletet (Tablet); // Paint widget ptPainter- & gt; Save (); PtPainter- & gt; translation (tOption.rect.topLeft ()); M_ptItemWidget- & gt; render (ptPainter); ptPainter- & gt; restore ();} QSize LayerItemWidgetDelegate :: sizeHint (const QStyleOptionViewItem & amp; toption, const QModelIndex and amp; TIndex) const {Q_UNUSED (top) Q_UNUSED (tIndex) QSize (m_ptItemWidget-> Minimum Width (), m_ptItemWidget-> Height ());} Bool La YerItemWidgetDelegate :: editorEvent (QEvent * Event, QAbstractItemModel * Model, Constant QStyleOptionViewItem & Options, Constellation QModelIndex & Index) {m_ptItemWidget-> propagateEvent (Event); M_ptItemWidget-> Seton Enabled (True); DEBUG_MESSAGE ("EVENT"); }    

You should read the documentation about the setItemWidget method . You can set widgets to show only some data, not to interact with this widget

Possible solutions, (this should be done, but a lot of tuning for this task is needed):.

  1. A representative that will attract the necessary control (or QPixmap :: grabWidget use your widget view cache and)
  2. Track mouse Events
  3. When Mouse QModelIndex - Make an editor for this item.
  4. Track editor events, and when the mouse leaves it - hide an editor and deposit the data

    But in your case, I think that you have your idea again Think about designing (if you do not have much):

    1. Create your own widget with a vertical layout
    2. Place your widgets there
    3. Handling model events (... profit!)

      Note: item views widgets Is designed to show data Hi amounts and they were not designed to communicate complex.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -