Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. delegate
    Log in to post

    • SOLVED Access item inside ListView via delegate
      QML and Qt Quick • qml listview button delegate • • Ratzz  

      14
      0
      Votes
      14
      Posts
      92
      Views

      @GrecKo , I mean without the button, when I edit the values of TextEdit, I should be able to get the modified text. I tried via property. It always gave me empty
    • UNSOLVED Referencing Column from a delegate
      QML and Qt Quick • delegate • • gabor53  

      4
      0
      Votes
      4
      Posts
      42
      Views

      @gabor53 i meant create a new custom property only for your purpose.
    • UNSOLVED Views - what are the correct rules to use models?
      QML and Qt Quick • model delegate design view choose • • jeanmilost  

      2
      0
      Votes
      2
      Posts
      51
      Views

      @jeanmilost I can't answer all your questions, as I'm not an expert on Qt's Model/View system, what I do know is, that all models have a QAbstractItemModel as base model and that is also the ABI for all views. For that reason alone, you can assign all models to all views. You will however not get a useful representation of all your data in all views. As I understand it, and anyone fell me to correct me here, the other higher level classes of models are only there to make your life easier, as in you do not have to implement all functions/functionalities of the whole AbstractItemModel class
    • SOLVED QCheckbox overlap with Table item value
      General and Desktop • qtableview delegate qstandarditem qcheckbox delegatemodel • • sayan275  

      3
      0
      Votes
      3
      Posts
      65
      Views

      @VRonin Thanks. It worked. We have used delegates because we have combobox, lineedit also. So we have put check for combobox, not to update via delegate.
    • SOLVED QSlider as QStyledItemDelegate: moving slider requires additional mouseclick
      General and Desktop • delegate qslider • • gde23  

      2
      0
      Votes
      2
      Posts
      80
      Views

      @gde23 said in QSlider as QStyledItemDelegate: moving slider requires additional mouseclick: So is there a way the slider can be grabbed directly from the first click? Currently not, no - the first click is the edit trigger.
    • SOLVED Problem with access to ListElement's proporty after delegate's function calling
      QML and Qt Quick • delegate listmodel handler • • Artiom  

      6
      0
      Votes
      6
      Posts
      88
      Views

      It really works! Thank you, IntruderExcluder, GrecKo.
    • SOLVED Different delegates in TableViewColumn depending on data
      QML and Qt Quick • tableview delegate qt 5.12 • • SebastianM  

      5
      0
      Votes
      5
      Posts
      238
      Views

      Cool, that's what I was looking for.
    • SOLVED Editor created by QStyledItemDelegate is not inheriting container width
      General and Desktop • delegate qstyleditemdele editor • • Colin James  

      2
      1
      Votes
      2
      Posts
      171
      Views

      I eventually managed to fix this by implementing updateEditorGeometry and calling editor->setGeometry(option.rect);. I should have looked into base class member functions sooner!
    • SOLVED ComboBox delegate on QSqlRelationalTableModel: setModelData?
      General and Desktop • delegate combobox relationaltable • • see_mountains  

      2
      0
      Votes
      2
      Posts
      436
      Views

      Ok, I have figured it out by myself. The key was looking at the comboBoxModel->data and getting the index from rows and coloumns. That's my solution: void comboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { if(QComboBox *cb = qobject_cast<QComboBox*>(editor)) { QString cbText = cb->currentText(); int vpe_index = -1; for (int row = 0; row < comboBoxModel->rowCount() ; row++) { if (comboBoxModel->data(comboBoxModel->index(row, 0)) == cbText){ vpe_index = comboBoxModel->data(comboBoxModel->index(row, 1)).toInt(); } } if (vpe_index == -1) { qDebug() << "Index not found"; } else { qDebug() << "Index set: " << model->setData(index, vpe_index, Qt::EditRole); } } else { QStyledItemDelegate::setModelData(editor, model, index); } }
    • UNSOLVED listView changes are updated only when delegates are destroyed
      QML and Qt Quick • listview delegate • • lionking_dexi  

      5
      0
      Votes
      5
      Posts
      1062
      Views

      @JonB Thank you for your explanation. I understand what i need to do, but i need a little help in making the right signals and slots. My project was setup using the "Using C++ Models in QML {tutorial}" as a guide. here the ToDoList class is set as the data in ToDoListModel class. In the ToDoList Calss there are: 1.appendItem() function, which emits the signals preItemAppended() and postItemAppended() 2.removeItem() funciton, which emits the signals preItemRemoved() and postItemRemoved() [these work fine] 3.similar to the appendItem() and removeItem() I am trying to make a setItemAt() function that will modify the existing data. but there was no steps in the tutorial to indicate how i could notify the model to emit the dataChanged() signal. I tried making my own signal in the data class and a slot in model class but i couldn't figure out how to connect them. the main function has a ToDoList object but no ToDoListModel object (ToDoListModel is just registered to qml). i am only familiar with using the connect(*sender,signal,*receiver, slot) function to connect. I suspect that it has something to do with the 'Q_PROPERTY(ToDoList *list READ list WRITE setList NOTIFY listChanged)' line in the ToDoListModel header file. following the tutorial I removed the NOTIFY listChanged part. summary:which signal do i need to emit from the data class(ToDoList) to have the model class (ToDoListModel) emit the dataChanged() signal?
    • SOLVED Problem with delegates: repeated editing of same cell in QTableWidget has delay of ca 1 second
      General and Desktop • qtablewidget delegate slow delay editing • • linuxbastler  

      14
      0
      Votes
      14
      Posts
      2822
      Views

      ok, the template solution is also working here. Thanks a lot for your help!
    • SOLVED ListView undefined reference to vtable for Custom Delegate (QStyledItemDelegate)
      General and Desktop • qt5 qlistview delegate qt5.9 qstyleditemdele • • CybeX  

      4
      0
      Votes
      4
      Posts
      2124
      Views

      Actually, since the base class already has a virtual destructor you can just remove the destructor of your derived altogether
    • using pixmaps as an alternative to openPersistentEditor() in an itemView
      General and Desktop • model delegate view editor • • mortbopet  

      2
      0
      Votes
      2
      Posts
      660
      Views

      I'm doing something similar in sort of objects property tree. It works pretty well for large number of items. Definitely a massive win over a widget per item approach. One difference to your approach is that I don't use grab(), but instead have the editors created by the delegate a static drawing function that uses QStyle::drawControl and friends to draw an image of itself. This is because I don't want to instantiate all the editor widgets upfront to grab them (I have a bunch of them and it takes time). It's sort of a trade-off because it can get out of sync with the actual widget look. Whether this is something you'd be interested in or not is up to you, but the general idea of drawing an image is a valid one.
    • UNSOLVED Delegate that paint entire widget area
      General and Desktop • delegate modelview painter • • RausoV  

      4
      0
      Votes
      4
      Posts
      954
      Views

      Hi Mr @VRonin suggested we looked at http://doc.qt.io/qt-5/qabstractscrollarea.html#maximumViewportSize so maybe yo u need to subclass view and return full area.
    • UNSOLVED Subclassed QSqlRelationalDelegate not working properly with SQlite view
      General and Desktop • qtableview delegate sqlite3 relational • • Qutie  

      4
      0
      Votes
      4
      Posts
      1273
      Views

      Did you already checked the bug report system to see if there was something related ? If not, please consider opening a new report providing a minimal compilable example showing the behaviour.
    • UNSOLVED Extended Custom Completer Example
      General and Desktop • delegate completer • • Sikarjan  

      2
      1
      Votes
      2
      Posts
      1328
      Views

      I made a small update on the code. In the delegate I reworked the highlight section: QAbstractTextDocumentLayout::PaintContext ctx; QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4); painter->save(); painter->translate(textRect.topLeft()); painter->setClipRect(textRect.translated(-textRect.topLeft())); // Highlighting text if item is selected if (optionV4.state & QStyle::State_Selected){ ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText)); QStyleOptionViewItem toolTip = option; initStyleOption(&toolTip, index.sibling(index.row(),2)); QToolTip::showText(QPoint(textRect.right() + 15, textRect.top()), toolTip.text ); } doc.documentLayout()->draw(painter, ctx); painter->restore(); This gives me a nice tool tip but not at the right location. I want it next to the completer but I cannot figure out how to get the coordinates. Since the delegate is not a widget I cannot use this->maptoglobal(). Any ideas on how I could position the tool tip next to the highlighted element?
    • UNSOLVED QML TreeView - how to apply delegate to certain items in the tree?
      QML and Qt Quick • qml model-view delegate treeview • • Haitham  

      9
      0
      Votes
      9
      Posts
      6762
      Views

      @6thC did your application consist of a tree and you could apply a delegate to specific items? because that's where I'm stuck now. I am still researching on how to connect QML with C++ and as usual if I figured out a way of applying delegates to specific items based on a logical condition (like your warning and maximum states), I will let you know. Thanks for your time bro!
    • UNSOLVED Delegate
      General and Desktop • delegate • • WhiteBeard  

      7
      0
      Votes
      7
      Posts
      1342
      Views

      Great ! What did you implement ? Also, since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum uses may know a solution has been found :)
    • UNSOLVED QTableWidget: Set specific row's color
      General and Desktop • qtableview qtablewidget delegate • • sunil.nair  

      10
      0
      Votes
      10
      Posts
      17789
      Views

      @VRonin hey it works. I created a separate qt project and it's working there. I will see if I am doing something wrong in my project. Actually the row to which I am trying to set a background color also has some color set to it in table widget stylesheet. Also tablewidget items also have a background color. I will check there. Thanks again.
    • UNSOLVED How to add QComboBox and TextField inside TreeView with delegate QML?
      QML and Qt Quick • qml qcombobox delegate treeview qabstractitemmo • • tamlong0205  

      4
      0
      Votes
      4
      Posts
      2684
      Views

      @tamlong0205 I think most of this can be done from C++ side. You can add a function in the model which can return what type is the data for current index. This function will be called from QML and depending upon its value use a Loader to load the specific delegate. Perhaps setting currentIndex in Component.onCompleted handler ? Create a C++ function which will store in info in the model itself i.e When you change the index in ComboBox call this function and update the value there and may be maintain a role to store this update.
    • Listview/delegates coloring
      General and Desktop • listview delegate color change newb • • Sydes  

      6
      0
      Votes
      6
      Posts
      1608
      Views

      Any reason why you can't use QStandardItemModel? in that case subclass QStyledItemDelegate and reimplement paint void QStyledItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_ASSERT(index.isValid()); QStyleOptionViewItem opt = option; initStyleOption(&opt, index); ///////////////////////////////////// // Set the background based on the content if(index.data().toInt()==1) opt.backgroundBrush = QBrush(Qt::red); ///////////////////////////////////// const QWidget *widget = option.widget; QStyle *style = widget ? widget->style() : QApplication::style(); style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget); }
    • SOLVED QML ListView memory performance
      QML and Qt Quick • listview delegate performance memory • • KroMignon  

      3
      0
      Votes
      3
      Posts
      2239
      Views

      @jpnurmi Thank's a lot! That's it :) Now everything works like a charm :) You saved my day!
    • UNSOLVED Propagate TAB key from delegate to custom editor
      General and Desktop • delegate event • • CarloEste  

      3
      0
      Votes
      3
      Posts
      1052
      Views

      I tried, but it doesn't work.
    • UNSOLVED Model views with pagination
      QML and Qt Quick • model delegate grid page navigation • • Mark81  

      8
      0
      Votes
      8
      Posts
      4304
      Views

      @Mark81 Even in JavaScript you have two models, you just don't typically think of it that way: model 1: the database, model 2: the results on the client side. Here, you have two models: 1 - the database, 2 - the QML side. So what you need to do is create a paginated model using LIMIT/OFFSET queries.
    • UNSOLVED QML: ListView highlightFollowsCurrentItem and shortest path
      General and Desktop • listview model delegate highlight • • Mark81  

      4
      0
      Votes
      4
      Posts
      1596
      Views

      @Mark81 If index is 0 then don't start the animation. Well something like: property int myIndex : 0 function animate(idx) { listAnimation.running = false var pos = list.contentY; var destPos; list.positionViewAtIndex(idx, ListView.Beginning); destPos = list.contentY; listAnimation.from = pos; listAnimation.to = destPos; listAnimation.running = true; } Timer { ... onTriggered: { if(myIndex==0) list.positionViewAtIndex(myIndex,ListView.Beginning); else animate(myIndex) myIndex++ if(myIndex==list.count-1) myIndex = 0 } }
    • UNSOLVED What is QHeaderView default delegate.
      General and Desktop • qtableview delegate qheaderview • • tokafr  

      2
      0
      Votes
      2
      Posts
      996
      Views

      HI, No it's not. You have the explanation here
    • SOLVED Qt 5.6 MapItemView issue
      QML and Qt Quick • qt5.6 model delegate mapitemview • • ginkgoguy  

      3
      0
      Votes
      3
      Posts
      1247
      Views

      Thanks for your efforts. As you said it works in a project I have a second look at my code. I'm not writing a Quick-App but a QWidget-App and use the map inside a QQuickWidget. I have read about another approach to embed qml content in a QWidget-App using QQuickView inside a QObject-Container. This approach works as expected. I don't know why it doesn't work with a QQuickWidget but my problem is solved. Best Regards
    • UNSOLVED Height animation does not work inside table view
      QML and Qt Quick • qml tableview delegate • • Rinat Veliakhmedov  

      2
      0
      Votes
      2
      Posts
      936
      Views

      I got a solution on SO: I should've used "height" instead of height inside PropertyAnimation.
    • SOLVED Multiple models in Map (QtLocation)
      QML and Qt Quick • model delegate map qtlocation • • Alexander_Lanin  

      4
      0
      Votes
      4
      Posts
      1512
      Views

      @Alexander_Lanin didn't see you already found it before I submit my reply...
    • SOLVED QListViewDelegate paint issue
      General and Desktop • qlistview delegate painter • • Rory_1  

      14
      0
      Votes
      14
      Posts
      6187
      Views

      just for addition: see this So i ncase you draw anti-aliased, the border-offset would just be the half of the border-width.
    • UNSOLVED Listview delegate: Loader.setSource() not working
      QML and Qt Quick • listview delegate loader item • • kylecorver  

      6
      0
      Votes
      6
      Posts
      2964
      Views

      @kylecorver Can you post the complete program? The original isn't a a valid Qml document, leading to guessing about which errors will or will not occur. The OS and Qt version used might also be relevant.
    • UNSOLVED How do I emit signal while clicking TableViewColumn?
      QML and Qt Quick • delegate mousearea tableviewcolumn • • Mira13  

      1
      0
      Votes
      1
      Posts
      515
      Views

      No one has replied

    • UNSOLVED checkbox column in tableview
      General and Desktop • delegate checkbox column • • Bazelboday  

      1
      0
      Votes
      1
      Posts
      2196
      Views

      No one has replied

    • Store extra information in QListWidget
      General and Desktop • qlistwidget delegate • • m_jero  

      2
      0
      Votes
      2
      Posts
      761
      Views

      Hi, Just store the full time in your model and use a QStyledItemDelegate to change the visualization part. It should be enough to just reimplement displayText. Hope it helps
    • dynamic Delegate component and use of DelegateModelGroup in DelegateModel
      General and Desktop • delegate dynamic delegatemodelgr • • Mephi  

      4
      0
      Votes
      4
      Posts
      1450
      Views

      @Mephi Hmm, sorry for that. I wasn't aware of it as i have never used it before. So digging in it seems that the attached properties of DelegateModel doesn't seem to work if the delegate is in separate file. Could be a bug I suppose. You can try reporting it here.
    • Using TableView as ListView-delegate
      QML and Qt Quick • listview tableview model delegate • • qwasder85  

      3
      0
      Votes
      3
      Posts
      979
      Views

      @p3c0 This sounds like a very easy solution, I'll try it out. Thank you.
    • pyqt delegate text wrapping sizeHint and paint
      General and Desktop • delegate paint sizehint • • lukeQt  

      1
      0
      Votes
      1
      Posts
      1284
      Views

      No one has replied

    • Do I have to write my own TableView headerDelegate from scratch?
      QML and Qt Quick • tableview delegate • • betty_crokker  

      2
      0
      Votes
      2
      Posts
      729
      Views

      @betty_crokker Why isn't there a TableViewHeaderDelegate widget that I can "inherit" and just modify the font? Or is there, and I just don't know where to look? There is no such way to do so. No such functionality provided yet. Is there an example somewhere showing how to get the UI for sorting to work? You can use the method described here. Basically it is a QML wrapper around QSortFilterProxyModel and works with ListModel.
    • (SOLVED) QML - How to get ListView height and width of it's children elements (possibly delegates)
      QML and Qt Quick • qml listview delegate component contentheight • • svyatoslav911512  

      9
      0
      Votes
      9
      Posts
      18201
      Views

      @Mertanian There is such a problem.