Navigation

    Qt Forum

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

    • UNSOLVED Why Qt is so underrated among developers
      Mobile and Embedded • qtableview • • Raftar1  

      2
      0
      Votes
      2
      Posts
      59
      Views

      Post copied from https://www.reddit.com/r/QtFramework/comments/fx6jfu/why_qt_is_so_underrated_among_developers/
    • UNSOLVED Creating custom model for QTableView
      General and Desktop • qtableview qt 5.12 • • Thank You  

      5
      0
      Votes
      5
      Posts
      43
      Views

      @Thank-You said in Creating custom model for QTableView: I want to add one row at the end of the table as show in the above picture Help me guys Already told you what you need to do. What help are you expecting? We don't write the code for you (we also have a lot of work to do!), we tell you what you need to do.
    • SOLVED QTableView reduce row height not working
      General and Desktop • qtableview row heigth • • gde23  

      4
      0
      Votes
      4
      Posts
      46
      Views

      thanks a lot, that did the trick :)
    • SOLVED Slow performance and large memory usage with QTableView in Qt 5.15
      General and Desktop • qtableview performance • • KaoN  

      24
      0
      Votes
      24
      Posts
      231
      Views

      @KaoN mmh the last Idea I have, would be updating your graphics drivers, those are most often an issue. After that, bring it to https://bugreports.qt.io
    • UNSOLVED segv when getting QFileInfo from subclassed QFileSystemModel
      General and Desktop • qtableview qabstractitemmo qfilesystemmode qmodelindex qt5.13.1 • • CybeX  

      2
      0
      Votes
      2
      Posts
      44
      Views

      What's the benefit of FileSystemModel::getFileInfo()? I would guess your this pointer is a nullptr
    • UNSOLVED One QHeaderView for multiple view
      General and Desktop • qtableview qheaderview • • dridk2  

      2
      0
      Votes
      2
      Posts
      50
      Views

      QHeaderView is a widget. You can't have one widget in two places at the same time. You can have two header views and sync them on change.
    • SOLVED Confusion about inserting new data into QTableModel
      General and Desktop • qtableview qtablemodel setdata • • lansing  

      4
      0
      Votes
      4
      Posts
      73
      Views

      @VRonin Thanks, a written example is a lot easier to understand. I was going through the Qt documentation over and over and couldn't find an good example for this.
    • 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 How to recent signal from proxyModel to model?
      General and Desktop • qtableview qsortfilterprox qabstracttablem • • zloi_templar  

      4
      0
      Votes
      4
      Posts
      44
      Views

      @VRonin yea, ty, already fix it
    • SOLVED Trying to programatically fill a model for QTableView
      General and Desktop • qtableview qabstracttablem • • aramaz  

      3
      0
      Votes
      3
      Posts
      55
      Views

      @Bonnie said in Trying to programatically fill a model for QTableView: Yes, the life cycle is definitely a problem. You should show the code when making the tabletModel a member of MainWindow. And there's no need to call show() when appending data. It turns out I was not initializing the table model in the constructor when making it a member. and you are correct the show() isn't needed. Now it all works. Thanks again!
    • SOLVED How to properly loop over QAbstractItemModel->setData() ?
      General and Desktop • qtableview • • christian20052  

      9
      0
      Votes
      9
      Posts
      494
      Views

      Although I still don't understand why setData returns false after the first selected row, this works. Thank you!
    • UNSOLVED QTableWidget/QTableView "word wrap" behavior, but without words (no spaces)?
      General and Desktop • qtableview qtablewidget stretch wordwrap new line • • oblivioncth  

      1
      0
      Votes
      1
      Posts
      737
      Views

      No one has replied

    • SOLVED QTableView does not show data when populating with QSqlQueryModel / stored procedure
      General and Desktop • qtableview qsqlquerymodel sql server stored procedur • • donnpie  

      3
      0
      Votes
      3
      Posts
      355
      Views

      So I tried the suggestions by @jwernerny. I dumped the QSqlQueryModel and went with a QStandardItemModel. TableView now displays correctly. Code now looks like this: void MainWindow::on_btnLoadTable_clicked() { conn = new Connection("LOCALHOST\\SQLEXPRESS", "Plants"); stdModel = new QStandardItemModel(this); conn->init(); //Set driver and connection options conn->open(); qry1 = new QSqlQuery(conn->db); const int COL_COUNT = 3; if (qry1->exec("spBatchesPerPlant")) { qDebug() << "Executing query..."; int row = 0; //used for counting rows in the query while (qry1->next()) //Loop through the results { for (int col = 0; col < COL_COUNT; col++) { stdItem = new QStandardItem(qry1->value(col).toString()); stdModel->setItem(row, col, stdItem); } row++; } ui->tableView->setModel(stdModel); } } Motto of the story: stored procedures generate forward only queries. QSqlQueryModel does not work for forward only queries, so use a standard item (or custom) model.
    • SOLVED QTableView on editing last row add new line
      General and Desktop • qtableview blank row • • Rhdr  

      6
      0
      Votes
      6
      Posts
      1393
      Views

      @vronin that looks like exactly it, thanks for the link! The translation shouldn't be a problem, most of the qt documentation is written in c++ anyway. Is there a way to mark your post as the answer instead?
    • UNSOLVED It's extremely slow to remove all rows from QTableView.
      General and Desktop • qtableview qstandarditem removerow qt5.12.1 • • Sungsong  

      9
      0
      Votes
      9
      Posts
      1337
      Views

      @JonB I added comments in my code. I think I should explain it clearly. Sorry... but please help.
    • UNSOLVED QTableView Empty ?
      General and Desktop • qtableview qsqltablemodel sqlite3 • • R-P-H  

      18
      0
      Votes
      18
      Posts
      815
      Views

      Yes you do, or you can make your own custom QAbstractTableModel that will return the content of your vector of records. Yes you do. However you can use an in-memory database if you don't want to have another database in a file.
    • SOLVED Add Qlabel as item in QTableview
      General and Desktop • qtableview qtablewidget qlabel qstandarditem • • sayan275  

      3
      0
      Votes
      3
      Posts
      1162
      Views

      @SGaist said in Add Qlabel as item in QTableview: QStyledItemDelegate Ok..I'll try with that. from google search maybe this kind of output it will give, which maybe as our requirement. Else, I have some lengthy approach..implement custom label with mousepressevent handled which emits the object name and add these custom labels, 20 in HLayout and add hlayouts in a vlayout... Thanks!
    • SOLVED QTableView, QStandardItemModel and underlying data in a QList
      General and Desktop • qtableview qlist qstandarditem objects underlyingdata • • Gerhard_Old  

      7
      0
      Votes
      7
      Posts
      1394
      Views

      Hi! Thank you very much for your help. I thought and I want to make little steps at first, so I changed my struct: // person.h struct person { int id; QStandardItem* name; QStandardItem* family; } Now I can directly use my members and append them. I do not need write access, but to show my objects directly in QAbstractTableModel is indeed a sexy idea. I am trying around with QModelIndex, club_model->item(), club_model->itemData() and roles, and when I am done with that, maybe I'll try my own model. For now, my question is solved! Regards Gerhard
    • UNSOLVED Disable scroll area in QTableView/QTableWidget
      General and Desktop • qtableview qscrollarea scrollarea scroll viewport • • Maluna34  

      4
      0
      Votes
      4
      Posts
      2352
      Views

      Unfortunately it seems that it's not enough to trigger the scrollbar of the parent. The solution I found is to set the fixedWidth of the table like this : int size{ 0 }; for (int i = 0; i < table->columnCount(); ++i) size += table->columnWidth(i); table->setFixedWidth(size);
    • SOLVED QSqlRelationalDelegate's default value
      General and Desktop • qt5 qtableview qsqltablemodel qsqlrelational • • Kot Shrodingera  

      6
      0
      Votes
      6
      Posts
      697
      Views

      So my final solution is: class SqlRelationalDelegate : public QSqlRelationalDelegate { Q_OBJECT public: StorageSqlRelationalDelegate(QObject* parent = nullptr) : QSqlRelationalDelegate(parent) {} QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override { editor = QSqlRelationalDelegate::createEditor(parent, option, index); return editor; } void destroyEditor(QWidget* editor, const QModelIndex& index) const override { QSqlRelationalDelegate::destroyEditor(editor, index); this->editor = nullptr; } QWidget* getEditor() const { return editor; } private: mutable QWidget* editor = nullptr; }; ... class TableView : public QTableView { Q_OBJECT public: StorageTableView(QWidget* parent = nullptr) {} void openPersistentEditor(const QModelIndex &index) { QTableView::openPersistentEditor(index); emit persistentEditorOpened(index); } signals: void persistentEditorOpened(const QModelIndex &index); }; ... connect(view, &TableView::persistentEditorOpened, [view] (const QModelIndex& index) { auto model = view->model(); auto delegate = qobject_cast<SqlRelationalDelegate*>(view->itemDelegate(index)); if (!delegate) qFatal("Delegate cast error"); delegate->setModelData(delegate->getEditor(), model, index); });
    • UNSOLVED Proper way of resizing model in QTableView
      General and Desktop • qtableview model mvc • • JoseTomasTocino  

      5
      0
      Votes
      5
      Posts
      726
      Views

      @VRonin That's really useful, thank you very much. Also I didn't know about the "Model test", that's nice too.
    • UNSOLVED Tree view for hierarchical SQL query?
      General and Desktop • qtableview sql qtreeview software design presentation • • elfring  

      3
      0
      Votes
      3
      Posts
      536
      Views

      I'll update this post once I go anywhere with it This feedback sounds promising. I am becoming more curious around another description for a similar use case: An associative table can be created. QStandardItem objects can be generated then based on table entries. Which ways would you like to recommend for the connection of entities to their relationship data?
    • UNSOLVED Default sort indicator order in QHeaderView
      General and Desktop • qtableview qheaderview sorting • • MrBolton  

      7
      1
      Votes
      7
      Posts
      2679
      Views

      I know the topic is quite old, but I experienced the exact same issue and this thread was popping up in my search. So, adding a QSortFilterProxyModel and enabling sorting with setSortingEnabled(true) sorts the table in descending order. I got the correct order when I explicitly specifying the order via indicator right before enabling the sort: table->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder); table->setSortingEnabled(true);
    • UNSOLVED How to make QTableView with QComboBox in one column.
      General and Desktop • c++ qt5 qtableview qcombobox • • arkadiusz97  

      2
      0
      Votes
      2
      Posts
      950
      Views

      What's the problem replacing the QSpinBox with a QComboBox in the example? Did you even try?
    • UNSOLVED Zoom In/Out QTableView with a frozen first column
      General and Desktop • c++ qtableview qgraphicsview zoomlevel • • MarKS  

      5
      0
      Votes
      5
      Posts
      994
      Views

      Do you mean custom graphicsView or tableView? If custom graphics view wouldn't it be too hard to reimplement everything? Any links or example would help.
    • UNSOLVED Do not draw a QTableView
      General and Desktop • qtableview c++ qt • • dima_slon  

      3
      0
      Votes
      3
      Posts
      403
      Views

      @JonB This adds a new, blank row at the end of the table model. But you do not set that row to hold your component / text? How to do it? I did not correctly understand what this function does, so if it's not hard for you. You can suggest how to insert text in the first free cell
    • SOLVED Replicate the contents of the current selected item in QTableView
      General and Desktop • qtableview signal & slot model-view view • • Arthur Araruna  

      7
      0
      Votes
      7
      Posts
      964
      Views

      @Arthur-Araruna said in Replicate the contents of the current selected item in QTableView: both column and row indices All you need to do is replace currentRowChanged with currentIndexChanged
    • SOLVED SQLite and QTableView: Custom sorting is slow
      General and Desktop • qtableview sqlite sorting • • YuriQ  

      2
      0
      Votes
      2
      Posts
      941
      Views

      I created custom model which works fast enough. It fetches and writes data using queries. Seems like working solution.
    • SOLVED How do I detect which column was clicked in a QTableview header
      General and Desktop • qtableview qheaderview column clicked • • mmikeinsantarosa  

      8
      0
      Votes
      8
      Posts
      5526
      Views

      @mmikeinsantarosa Hi just to be clear You do not name the parameter when using a function in a connect. Nor for signal OR the slot. So if you function is like void MySlot( int ID, QString Name) ( in .h and cpp) you would only use as MySlot( int, QString) for connect.
    • UNSOLVED is it necessary to use connection for frequent gui updation ??
      General and Desktop • qtableview signal & slot • • vasu_gupta  

      2
      0
      Votes
      2
      Posts
      557
      Views

      Hi it will only be a problem if you make too long lasting loop. Then it will stop redrawing.
    • SOLVED QtableView setSortingEnabled  forcing sortByColumn()
      General and Desktop • qtableview qt5.9 sorting qtableview c++ • • mapuna  

      23
      0
      Votes
      23
      Posts
      15997
      Views

      You could set default sorting column to -1 by QHeaderView::setSortIndicator like this yourTableView->horizontalHeader()->setSortIndicator(-1, Qt::AscendingOrder); before running yourTableView->setSortingEnabled(true); because QTableView::setSortingEnabled uses QHeaderView::sortIndicatorOrder and QHeaderView::sortIndicatorSection to identify by which column should model be sorted. Note that documentation of QHeaderView::setSortIndicator tells that not all models support setting sort column to -1 and may even crash in this case.
    • SOLVED SQL query not loading back
      General and Desktop • qtableview button search results • • Lasith  

      11
      0
      Votes
      11
      Posts
      2047
      Views

      @VRonin I got it corrected! searchProxy->setSourceModel(modal); ui->tableView->setModel(searchProxy); should be put inside the search button method!
    • SOLVED QTableView: Cells value gets cleared when editing
      General and Desktop • qtableview qt5.9 qtableview c++ • • mapuna  

      2
      0
      Votes
      2
      Posts
      950
      Views

      The answer in stackoverflow is correct. Is there no other way to get notified when an Edit begins? just declare and emit your custom signal in the delegate subclass Remember 1 model can service multiple views so, normally, the model should not depend on the state of the view or delegate
    • SOLVED Making Qtableview cell autosize
      General and Desktop • qtableview database autosize retrieve • • Kushan  

      4
      0
      Votes
      4
      Posts
      922
      Views

      @Kushan Or you can use resizeColumnsToContents() method for the same.
    • UNSOLVED QTableView vs subclassing QAbstractTableModel
      General and Desktop • qtableview qtreewidget modelview qabstracttablem • • Electric-Gecko  

      4
      0
      Votes
      4
      Posts
      2777
      Views

      You can use either QTreeWidget, QTableWidget, QTreeView+QStandardItemModel, QTableView+QStandardItemModel, QTreeView+QAbstactTableModel subclass, QTableView+QAbstactTableModel subclass for what you are trying to do. I would go with a QT*View+QStandardItemModel (tree or table doesn't matter). The functionalities you describe are: only some columns will be editable use QStandardItem::setFlag Entering a value in the cents column (a logarithmic measure of frequency) will change the value in the hertz column, and vice versa connect a slot to QStandardItemModel::dataChanged signal There will be a button next to the table to add an additional note to the scale connect a slot that calls QStandardItemModel::insertRows to the QPushButton::clicked signal
    • UNSOLVED QSqlTableModel, QSqltableView не работают в релизе.
      Russian • qtableview qsqltablemodel • • Oles  

      2
      0
      Votes
      2
      Posts
      821
      Views

      Так проверьте соединение при запуске. И может, драйвер для SQLite собран только дебаговый? Надо и релизный тоже собрать.
    • UNSOLVED How to prevent QTableView/QTreeView doing query/sorting multiple times?
      General and Desktop • qtableview qtreeview sorting • • JonB  

      11
      0
      Votes
      11
      Posts
      4479
      Views

      @MrBolton Sorry, I really don't understand your comment. Precisely the point is that with "bigger data sets" you would have to fetch all the data, which is incredibly slow and may well exceed available memory. (OTOH, if the dataset is "small" the overhead of re-query compared to holding all the previous rows locally is also "small".) As a rule of thumb, one always wants as much work to be done at the server side as possible, not client side. Let's say the table has a million rows and the query I want to pose is: SELECT * FROM table ORDER BY column LIMIT 100 Very approximately, pushing the ORDER BY to the server instead of into a QSortFilterProxyModel will run 10 thousand times faster and use one ten-thousandth of the client memory. That's why I would be very careful before advising people to use QSortFilterProxyModel without understanding the ramifications!
    • SOLVED speed up QTableview with large data
      General and Desktop • qtableview qtableviespeed • • oxycoder  

      5
      0
      Votes
      5
      Posts
      6078
      Views

      Thanks everyone for answer. I am end up with write my own models, the load time reduce to 3s for 30k row and 150 col each.