Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. qitemdelegate

    Log in to post
    • All categories
    • MasterBLB

      Unsolved Custom QStyledItemDelegate - strange behavior on closing
      General and Desktop • qitemdelegate • • MasterBLB

      9
      0
      Votes
      9
      Posts
      337
      Views

      MasterBLB

      Ok, this paste page works:
      .h https://paste.ofcode.org/uiz7UuRsAYhWJVzN2r76MQ
      .cpp https://paste.ofcode.org/GsvM6EBgtXyqk2YuYKBCgs

    • H

      Unsolved Animation of QItemDelegates
      General and Desktop • qtreeview animation qitemdelegate • • H. Krishnan

      4
      0
      Votes
      4
      Posts
      566
      Views

      SGaist

      Hi,

      One alternative could be to use QRubberBand and draw it on top of the lines/cells you are interested in.

    • michalos

      Solved Wrong rich text height (QTextDocument) in item rendered by custom item delegate
      General and Desktop • windows linux qitemdelegate sizehint rich text • • michalos

      2
      0
      Votes
      2
      Posts
      1801
      Views

      michalos

      Terribly sorry, but it turned out to be my fault all along.

      The line responsible was:

      textDoc.setDocumentMargin(0);

      in the sizeHint() method.

    • ssokolow

      Unsolved How do I customize icon scaling behaviour in a QListView?
      General and Desktop • x11 qicon qlistview qitemdelegate icons • • ssokolow

      9
      0
      Votes
      9
      Posts
      6338
      Views

      ssokolow

      @hskoglund I already have an underlying data store and I'm using a subclass of QAbstractTableModel to bridge it into a Qt GUI.

      Making two in-memory copies of that data store and then jerry-rigging View-like synchronization between the actual data and two widget-specific data stores (plus all the requisite automated testing to make sure it works reliably) seems like the exact opposite of what I want.

    • A

      Solved Show HTML content in QTableView column while keeping BackgroundColorRole works
      General and Desktop • qt 5.7 qtableview qitemdelegate qstyleditemdele qstandarditemmo • • alizadeh91

      2
      0
      Votes
      2
      Posts
      1476
      Views

      raven-worx

      @alizadeh91
      Either you paint it yourself since you already have the QModelIndex at hand:

      QColor color = index.data( Qt::BackgroundColorRole ).toColor();

      or by letting the style paint the stuff. Note that this also paints the selected background.

      style->drawPrimitive( QStyle::PE_PanelItemViewItem, &option, painter, widget );
    • B

      Unsolved Problem with pressing TAB key during QTableView cell edit
      General and Desktop • qt4.8 qtableview qitemdelegate editor tab • • Ben35

      4
      0
      Votes
      4
      Posts
      4261
      Views

      B

      I think i've found a solution.

      First, i install an eventFilter in my custom editor widget B on the internal spinbox :

      internalSpinbox->installEventFilter(this);

      Then, i implement eventFilter to treat the events on the spinbox and duplicate them to the parent:

      bool AbstractRatioQuantitySpinbox::eventFilter(QObject *object, QEvent *event) { // cf http://stackoverflow.com/questions/12145522/why-pressing-of-tab-key-emits-only-qeventshortcutoverride-event if (event->type() == QEvent::KeyPress) { auto keyEvent = static_cast<QKeyEvent *>(event); if (keyEvent->key() == Qt::Key_Tab || keyEvent->key() == Qt::Key_Backtab) { QApplication::postEvent( this, new QKeyEvent(keyEvent->type(), keyEvent->key(), keyEvent->modifiers())); return true; } } else if (event->type() == QEvent::FocusOut) { auto focusEvent = static_cast<QFocusEvent *>(event); QApplication::postEvent(this, new QFocusEvent(focusEvent->type(), focusEvent->reason())); return false; } return QWidget::eventFilter(object, event); }
    • Sudo007

      Unsolved Qt Application gets freezed due to read huge data from SQLite database periodically
      General and Desktop • qtableview qitemdelegate • • Sudo007

      5
      0
      Votes
      5
      Posts
      1474
      Views

      S

      @Sudo007 said:

      hi
      I have created a class customDelegate (inherits QItemDelegate) in my Qt applicatrion and i created setEditor() function.But the delegate is not visible in the QTableView , untill i click on the row.
      How to fix the issue?

      How did you implement the paint() in your custom delegate ? As you are adding different widget in each cell, you need to paint a fake widget (QPushButton) using QApplication::style()->drawControl(QStyle::CE_PushButton, &btn,painter); where btn is QStyleOptionButton, then in createEditor() you create an instance of QPushButton.

    • Joel Bodenmann

      Solved Custom QItemDelegate works in QTableView but not QTreeView
      General and Desktop • qitemdelegate item delegate • • Joel Bodenmann

      8
      0
      Votes
      8
      Posts
      5009
      Views

      Joel Bodenmann

      At the end, @SGaist pointed me to this implementation of a checkbox item delegate which works very well.

    • M

      Unsolved Changing content of part of QTableWidget after editiong
      General and Desktop • qtablewidget qitemdelegate qmodelidex • • michelson

      4
      0
      Votes
      4
      Posts
      1530
      Views

      kshegunov

      @michelson said:
      Hello,

      I assumed i had to reimplement QItemDelegate::setModelData(...)

      I think this should suffice for your case. You can of course always create your own model as @SGaist suggested. As for your request for additional material:

      Here is an overview of the model-view framework A simple spinbox delegate example Icons example that uses delagets

      I hope this helps.
      Kind regards.

    • W

      Unsolved QListView with Groups
      General and Desktop • qlistview qitemdelegate modelview • • walkingTarget

      3
      0
      Votes
      3
      Posts
      2576
      Views

      W

      I think I take your meaning. As I geared up to subclass QAbstractItemView, it also became evident how niche my new class would be. Based on this, I decided to take your advice of composing a custom widget.

      If anyone should want to subclass QAbstractItemView, this is a good article to get you started.

    • M

      Solved QItemDelegate with QTableWidget, access problem
      General and Desktop • qitemdelegate qtablewidget editor • • michelson

      6
      0
      Votes
      6
      Posts
      3123
      Views

      SGaist

      QComboBox has a addItems where you can directly use your QStringList, so no need for the loops. And again, you should not use static_cast like that, use object_cast.

      You're lucky it's not crashing because you only handle column 1 where you know you create a QComboBox. You should move these two lines under the if protection.

    • C

      setEditorData not being called in Custom Delegate
      General and Desktop • seteditordata custom delegate qitemdelegate • • Code_Wrangler

      3
      0
      Votes
      3
      Posts
      1930
      Views

      SGaist

      Hi and welcome to devnet,

      The logic is the following:

      You create your widget in createEditor You get the data from that widget in setModelData, it's the first parameter of the function. You just have to cast it to the right type using qobject_cast

      Hope it helps

    • B

      Creating a calendar using QTableWidget with QItemDelegate
      General and Desktop • qtablewidget qitemdelegate • • Binary91

      20
      0
      Votes
      20
      Posts
      5568
      Views

      SGaist

      The QTableWidgetItem is essentially a data container, it doesn't know about any editor.

      It's the delegate that uses a factory that will return the corresponding editor based on the item content type.

    • Joel Bodenmann

      QItemDelegate sizeHint() with QComboBox
      General and Desktop • qitemdelegate • • Joel Bodenmann

      7
      0
      Votes
      7
      Posts
      4359
      Views

      Joel Bodenmann

      @Harb When I understood correctly a column of a QTableView which has a delegate assigned will automatically resize itself to the QItemDelegate::sizeHint() size. Therefore, I could return the required width of the column to display the full text in the cell, right?

      My custom delegate uses a QComboBox. The combobox is populated with items of different length. Now, let's assume there is just one row in the table and the item in the cell with the custom delegate is the item in the combobox with the shortest width. Therefore, the column will be just wide enough to display that text. When the user then clicks on the cell and the combobox dropdown shows up the user will not be able to see entries in the combobox which are longer. Items in the combobox which are longer than the width of the column will be shorted and three dots will be inserted.

      I took a screenshot so you can see what I mean: http://paste.ugfx.org/sores/7505d64a54e0/bcdde374e0fc.jpg
      As you can see there is one item in the dropdown which cannot be displayed in full length because the column width is too small.

      What I would like to do is using the QItemDelegate::sizeHint()to return the QComboBox::sizeHint() so the column will automatically be wide enough to display all items (because the QComboBox::sizeHint() returns the size so all items can be displayed.

    • scastiello

      QItemDelegate::createEditor runs 2 times in first edition
      General and Desktop • qitemdelegate qtreeview • • scastiello

      2
      1
      Votes
      2
      Posts
      1285
      Views

      C

      I have the same problem.
      Does anybody have any solution?
      Thank you.