Navigation

    Qt Forum

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

    • SOLVED QTableView clicked() not triggering when dragging and selecting a range of data in the table?
      General and Desktop • qtableview tableview table table view • • R-P-H  

      7
      0
      Votes
      7
      Posts
      127
      Views

      @jsulm said in QTableView clicked() not triggering when dragging and selecting a range of data in the table?: @R-P-H Mouse click means that mouse button was pressed AND released over same widget. Pressing mouse button down over one widget and releasing it over another isn't a click. You can use https://doc.qt.io/qt-6/qabstractitemview.html#pressed pressed() worked for me. Thanks !
    • SOLVED How to connect child tableview to parent model?
      Qt for Python • pyqt5 tableview • • judethedude  

      6
      0
      Votes
      6
      Posts
      110
      Views

      @JonB ok. I'm picking up what you're laying down. I went through my code and made sure my structure is actually following the patterns I've decided on. To answer your question, I do need access to both the proxy model and source model, but thanks for clarifying the distinction. Thank you for your time!
    • UNSOLVED QTableView's widgets not moving when the header is resized.
      General and Desktop • qtableview tableview setindexwidget • • griffonoak  

      2
      0
      Votes
      2
      Posts
      92
      Views

      Could you share a minimal example please?
    • SOLVED QTableView + QStandardItemModel + custom delegate = strange behaviour
      General and Desktop • tableview delegate • • artwaw  

      3
      0
      Votes
      3
      Posts
      124
      Views

      @SGaist You are, as usual, right and I am the absolute moron :D I forgot to take into the account starting point of the cell in paint... Too much time has passed since I had to write the delegate it seems. The solution of the problem was correcting the drawPixamp starting point (add opt.rec.x() and opt.rect.y() respectively): painter-drawPixmap(QPoint(opt.rect.x()+opt.rect.width()/2,opt.rect.y()+opt.rect.height()/3),px.scaled(opt.rect.width(),opt.rect.height()/2,Qt::KeepAspectRatio,Qt::SmoothTransformation)); Thank you for this quick reminder! Cheers, A.
    • UNSOLVED Missing Sort Indicators for Table Columns
      QML and Qt Quick • qml tableview • • Futster  

      1
      0
      Votes
      1
      Posts
      110
      Views

      No one has replied

    • SOLVED how to access data from a delegate's component.
      QML and Qt Quick • qml tableview delegate qt5.15.2 tableviewcolumn • • vinaygopal  

      4
      0
      Votes
      4
      Posts
      262
      Views

      The model should provide this information for you. Create a role in the model which will return the correct value for any given cell. On QML side, just access that role and display it directly. No need for any get() method (which, by the way, is called data() https://doc.qt.io/qt-5/qabstractitemmodel.html#data, not get()).
    • UNSOLVED QML HorizontalHeaderView not working as expected
      QML and Qt Quick • qml tableview horizontalheade • • raphasauer  

      3
      0
      Votes
      3
      Posts
      382
      Views

      This question was asked on stackoverflow as well. Just posting this here because the accepted answer was useful. Another approach would be to anchor the table below the header. TableView { id: tableView anchors.top: horizontalHeader.bottom model: TableModel { } }
    • UNSOLVED TableView does't update, but list into model is full
      QML and Qt Quick • qml tableview empty table • • warcomeb  

      5
      0
      Votes
      5
      Posts
      261
      Views

      Make a role for Qt::DisplayRole and call it "display". Then return data by column like you are doing to support tables. If I remember correctly TableViews are stuck on using the display role. ListViews seem to be more flexible. I don't know why though. I had to use 2 methods to support both listviews and tableviews if I remember corrrectly. You should only have to use the word "display" to support this role in your delegates. You can add it as another case to your role case so you can support both types of views.
    • UNSOLVED Qtableview mouse move
      General and Desktop • tableview qstyleditemdele • • charry  

      7
      -1
      Votes
      7
      Posts
      504
      Views

      Please take a look at your post above - do you really think we can read something meaningful out of it. Please use the <code> - tags to make it more readable and reduce your code as much as possible so only the problem and nothing else is in there.
    • UNSOLVED Export QML TableView as excel file
      QML and Qt Quick • qml tableview excel • • Babs  

      2
      0
      Votes
      2
      Posts
      555
      Views

      @Babs Take a look at https://wiki.qt.io/Handling_Microsoft_Excel_file_format
    • UNSOLVED MouseArea works incorrectly inside TableView's delegate
      QML and Qt Quick • tableview • • Dmitriano  

      20
      0
      Votes
      20
      Posts
      1033
      Views

      @jeremy_k Unfortunately, my MouseArea that covers the entire view and finds the delegate does not detect row insertion. For example on the picture below two rows surrounded with green were inserted (with beginInsertRows/endInsertRows) and MouseArea stopped responding to the clicks on the last two rows surrounded with red: Below I provided the source code of the entire TableView as it is now in my project: TableView { id: table anchors.fill: parent columnSpacing: 5 rowSpacing: 3 clip: true property var columnWidths: [100, 80, 80, 20, 20, 20, 90, 90]; columnWidthProvider: function (column) { return columnWidths[column]; } property var rowHeight: 40 rowHeightProvider: function (column) { return rowHeight; } ScrollBar.horizontal: ScrollBar{} ScrollBar.vertical: ScrollBar{} ScrollIndicator.horizontal: ScrollIndicator { } ScrollIndicator.vertical: ScrollIndicator { } MouseArea { //id: ma anchors.fill: parent //hoverEnabled: true onClicked: { var index = Math.floor((mouse.y - table.originY) / (table.rowHeight + table.rowSpacing)); console.log("index:", index, " mouse: (", mouse.x, "," , mouse.y, ") table.origin: (", table.originX, ",", table.originY + ") table.content: (", table.contentX, ",", table.contentY + ")") var item = table.model.rowKey(index) if (item) window.openMarket(item) } } QtObject { id: enumSymbols property string spotAllowed: "S" property string marginAllowed: "M" property string isolatedMarginAllowed: "I" } delegate: DelegateChooser { role: "type" DelegateChoice { roleValue: "symbol" delegate: SymbolCell { item: model.item } } DelegateChoice { roleValue: "price" delegate: Text { horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter text: { var val = model.item[model.name]; return val ? val.toFixed(model.item.pricePrecision) : ""; } } } DelegateChoice { roleValue: "signal" delegate: Text { horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter text: TimeFormat.ago(model.item.signalTime, timeMachine.now) color: model.item.signalTime ? "black" : "gray" } } DelegateChoice { roleValue: "enum" delegate: Text { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: model.display ? enumSymbols[model.name] : "" color: "#1e73cd" } } DelegateChoice { roleValue: "zparams" delegate: Text { property var zparams: model.item[model.name] horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter text: zparams ? "(%1, %2, %3)".arg(zparams.lag).arg(zparams.threshold.toFixed(2)).arg(zparams.influence.toFixed(2)) : qsTr("No") color: zparams ? "black" : "gray" } } DelegateChoice { roleValue: "check" delegate: CheckBox { checked: model.item[model.name]; onClicked: { table.model.beginUpdateItem(model.item) model.item[model.name] = checked table.model.endUpdateItem(model.item) } } } DelegateChoice { delegate: Text { verticalAlignment: Text.AlignVCenter text: model.item[model.name] } } } } If I refresh my TableView with beginResetModel/endResetModel MouseArea starts to work correctly.
    • SOLVED HorizontalHeaderView not calling headerData() of QAbstractTableModel's child
      QML and Qt Quick • qml tableview horizontalheade • • noone  

      2
      0
      Votes
      2
      Posts
      468
      Views

      my bad. I got answer in stack overflow The problem is caused by a naming conflict between the Button's display property and the role. The solution is to access the role through the model explicitly: delegate: Button { text: model.display }
    • SOLVED TableView with exapanding columns
      QML and Qt Quick • qml tableview layout • • noone  

      5
      0
      Votes
      5
      Posts
      324
      Views

      adding onWidthChanged: forceLayout() with columnWidthProvider to TableView works
    • SOLVED How to add a component onto the whole row of a multi-column TableView?
      QML and Qt Quick • tableview row anchoring multi-column • • jeanmilost  

      5
      0
      Votes
      5
      Posts
      401
      Views

      @jeanmilost Because of z ordering issues between delegates you will most likely need a popup.
    • SOLVED MouseArea prevents the parent scrolling to work properly
      QML and Qt Quick • tableview mouse mousearea scroll mouseevents • • jeanmilost  

      2
      0
      Votes
      2
      Posts
      395
      Views

      Finally I searched a while by myself, and I think I may answer my own question. Although I couldn't completely resolve my issue, I noticed that the answer is hidden in the other MouseArea events. For example, by handling the onPressed event and adding the mouse.accepted in several key locations, I could let the component take care of the scrolling when the left mouse button is pressed, whereas the right click opens a popup menu. My conclusion is that there is no ready-to-use way, i.e there is no parameter to activate in the MouseArea itself which may resolve this kind of issue, and the solution is a good balance between activating different parameters in the different functions.
    • SOLVED How to add rows automatically with sleep?
      General and Desktop • qthread tableview sleep • • SoleyRan  

      3
      0
      Votes
      3
      Posts
      358
      Views

      @Christian-Ehrlicher Thank you very much! It solved my problem perfectly :)
    • UNSOLVED Emulating ListView as TableView
      QML and Qt Quick • qml listview tableview view • • Ahti  

      6
      0
      Votes
      6
      Posts
      348
      Views

      @fcarney I am new to Qt so don't anything about Loader and Can you please take a look at this question too: https://forum.qt.io/topic/111852/inconsistency-between-model-and-view-while-updating-qsqltablemodel-cell
    • SOLVED DelegateChooser creates delegates in other context
      QML and Qt Quick • tableview qt 5.12 delegatechooser • • SebastianM  

      7
      0
      Votes
      7
      Posts
      621
      Views

      @SebastianM great that you managed to figure it out. It's a bit difficult to read all this on a mobile screen so excuse my previous posts 🙈 Never the less, thanks for charing the answer
    • SOLVED Different delegates in TableViewColumn depending on data
      QML and Qt Quick • tableview delegate qt 5.12 • • SebastianM  

      5
      0
      Votes
      5
      Posts
      861
      Views

      Cool, that's what I was looking for.
    • SOLVED DelegateChooser does not work
      QML and Qt Quick • tableview delegatechooser • • Dmitriano  

      2
      0
      Votes
      2
      Posts
      692
      Views

      hi @dmitriano Window { visible: true width: 640 height: 480 title: qsTr("Hello World") TableView { anchors.fill: parent columnSpacing: 1 rowSpacing: 1 clip: true model: TableModel {} delegate: DelegateChooser { role: "type" DelegateChoice { roleValue: "lab2" delegate: Rectangle { Text { id: label2 text: "type delegate" } } } DelegateChoice { // roleValue: "String" // default delegate delegate: Rectangle { color: ms.containsMouse ? "#d2cc01" : "lightgrey" MouseArea{ anchors.fill: parent hoverEnabled: true id:ms } implicitWidth: defaultLabel.implicitWidth + 8 implicitHeight: defaultLabel.implicitHeight + 4 Text { id: defaultLabel text: tabledata } } } } } }
    • SOLVED QAbstractTableModel::removeRows() implementation
      QML and Qt Quick • qml tableview • • Babs  

      4
      0
      Votes
      4
      Posts
      1243
      Views

      Well, your model is a "wrapper" around your data structure. Take a look at the Creating New Models in the Model View chapter of QT's documentation.
    • UNSOLVED Is it possible through qml javascript change the value of an delegate of a TableViewColumn?
      QML and Qt Quick • qml tableview model tableviewcolumn • • Nmaster88  

      1
      0
      Votes
      1
      Posts
      266
      Views

      No one has replied

    • UNSOLVED Is there a way to have subheader on a TableView?
      QML and Qt Quick • tableview tableviewcolumn • • Nmaster88  

      1
      0
      Votes
      1
      Posts
      282
      Views

      No one has replied

    • SOLVED How to change models using TableView column click event
      QML and Qt Quick • qml tableview listmodel onclick • • Flesh  

      2
      0
      Votes
      2
      Posts
      848
      Views

      @Flesh Romha Korev on stackoverflow.com gave me this answer: onSortIndicatorColumnChanged: tableView.model = (sortIndicatorColumn == 0) ? myListModel1 : myListModel2 onSortIndicatorOrderChanged: tableView.model = (sortIndicatorColumn == 0) ? myListModel1 : myListModel2
    • UNSOLVED DelegateChooser not working with TableView and QAbstractTableModel
      QML and Qt Quick • tableview delegatechooser • • notsak  

      1
      0
      Votes
      1
      Posts
      372
      Views

      No one has replied

    • UNSOLVED How to filter out columns in the new Quick Controls 2.12 TableView?
      QML and Qt Quick • tableview qsqltablemodel quick controls models qml components • • ivarec  

      1
      0
      Votes
      1
      Posts
      285
      Views

      No one has replied

    • UNSOLVED TableView rowDelegate how to take row index?
      QML and Qt Quick • qml tableview rowdelegate • • Galbarad  

      3
      0
      Votes
      3
      Posts
      1268
      Views

      but in MouseArea in row delegate styleData.row - available following code show right click menu for row in place where mouse clicked rowDelegate: Rectangle { id: rdRow height: 30 MouseArea { id: maRow anchors.fill: parent acceptedButtons: Qt.RightButton onClicked: { console.log("right click on row", styleData.row, mouseX, mouseY, tvMain.flickableItem.contentY) if ((styleData.row || (styleData.row === 0)) && (mouse.button === Qt.RightButton)) { currentRowIdxForMenu = styleData.row cmRow.x = mouseX cmRow.y = mouseY + styleData.row * rdRow.height - tvMain.flickableItem.contentY cmRow.open() } } } }
    • SOLVED what's the meaning of row in tableView::rowMoved(int row, int oldIndex, int newIndex)?
      General and Desktop • tableview rowmoved • • brozo77  

      2
      0
      Votes
      2
      Posts
      335
      Views

      I have download the source code. And find no use of the param row. So it's redundant. Close the question, thanks!
    • SOLVED How to show QSqlQuryModel in QML?
      QML and Qt Quick • qml sql tableview qsqlquerymodel • • noone  

      3
      0
      Votes
      3
      Posts
      555
      Views

      Hi, Add a setter to your model that is Q_INVOKABLE and pass your query through it. Don't forget to add proper error checking to give feedback to your user if something goes wrong.
    • SOLVED Loading data from sqlite database
      General and Desktop • qtcreator tableview sqlite button • • Kushan  

      10
      0
      Votes
      10
      Posts
      5316
      Views

      What was the problem ?
    • UNSOLVED qml TableView and group of columns
      QML and Qt Quick • tableview tableviewcolumn • • BePie  

      1
      0
      Votes
      1
      Posts
      510
      Views

      No one has replied

    • SOLVED Searching word found after several clicks!
      General and Desktop • qtcreator tableview button search • • Lasith  

      4
      0
      Votes
      4
      Posts
      1250
      Views

      Hi, More likely that not all your database data are loaded in memory. You would have to call fetchMore however beware that if you have big tables it's going to cost you more in RAM.
    • UNSOLVED TableView and Columns
      QML and Qt Quick • tableview tableviewcolumn • • RostV  

      1
      0
      Votes
      1
      Posts
      499
      Views

      No one has replied

    • UNSOLVED Enter manually in TableView
      QML and Qt Quick • qml tableview • • alemio  

      1
      0
      Votes
      1
      Posts
      529
      Views

      No one has replied

    • TableView with Controls 2
      Announcements • qml qtquick tableview grid • • Eluvatar  

      2
      2
      Votes
      2
      Posts
      1351
      Views

      Thank you for sharing!
    • QCompleter in QTableView: show always, even before user input
      General and Desktop • c++ tableview view completer completion • • azrdev  

      6
      0
      Votes
      6
      Posts
      4773
      Views

      @raven-worx said in QCompleter in QTableView: show always, even before user input: declare the m_Editor variable as mutable. This makes it compile (even though I'm not sure about the implications), but it doesn't help me: there is no Show event handled in editorEvent ever (tested with printf-debugging - yes, before the test for QLineEdit), I'm only getting Mouse events. @SGaist said in QCompleter in QTableView: show always, even before user input: Something like completer->popup()->show(); should do what you want. Nope, does not help. I figured (using qDebug, again), the place where I should put my popup-opening call is setEditorData. In there, I receive the QLineEdit and it's QCompleter: But I cannot make it show the popup. I tried now: completer->setCompletionPrefix(index.data(Qt::EditRole).toString()); completer->complete(); completer->popup()->show(); Note: Sometimes the popup is shown for a very short time, but immediately hides. When repeatedly entering & leaving edit mode this only works the first time.
    • UNSOLVED Text wrap in TableView
      QML and Qt Quick • qml tableview wordwrap • • DanielJG  

      1
      0
      Votes
      1
      Posts
      1224
      Views

      No one has replied

    • SOLVED Reordering TableView with drag and drop
      General and Desktop • tableview setpixmap drag and drop t moveaction • • PeterPan32  

      3
      0
      Votes
      3
      Posts
      1702
      Views

      Sounds great, but I get some runtime error: QPainter::begin: Paint device returned engine == 0, type: 2 QWidget::render: Cannot render with an inactive painter Edit: There is some modification on your suggested code neccessary: const QModelIndex& index = currentIndex(); // Render the pixmap QPixmap pixmap(visualRect(index).size()); //pixmap. render(&pixmap, QPoint(), visualRect(index)); // Create the drag QDrag* drag = new QDrag(this); drag->setPixmap(pixmap); ... But anyhow it renders the cell of one index above the selected one. Maybe that has something to do with the offset parameter (second one in render). Edit2: The proper QRect can be calculated with the height of the horizontal header: render(&pixmap, QPoint(0,0), visualRect(index).translated(0, horizontalHeader()->height() ));