Navigation

    Qt Forum

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

    • SOLVED QTableWidget Model (CellWidget) And LimeReport problem
      General and Desktop • qtablewidget model limereport • • Proton Phoenix  

      5
      0
      Votes
      5
      Posts
      58
      Views

      @SGaist That's What i want bro Really Thank you <3
    • UNSOLVED QWidget size in designer form is not respected.
      General and Desktop • qwidget qtablewidget • • ozcanay  

      2
      0
      Votes
      2
      Posts
      52
      Views

      According your first picture you're missing a layout on the widget.
    • UNSOLVED Remove CellWidget from QTableWidget when focus out
      General and Desktop • qtablewidget setcellwidget remove widget • • shobhitmittal  

      4
      0
      Votes
      4
      Posts
      76
      Views

      @shobhitmittal said in Remove CellWidget from QTableWidget when focus out: As far as I understand, if I need to show a comboBox in a tableWidget cell, I need to use setCellWidget No, you do not need to do this (via setCellWidget()). Search the QTableWidget docs page, and that of QTableView from which it inherits, for edit. Qt has the "framework" for going in & out of edit mode on a cell without you having to to ever call setCellWidget. I believe that by doing that you will find that if the user clicks away from the combobox editor (which appears when editing starts) the framework will get rid of that comboxbox for you. Actually the editor facilities are shown under QAbstractItemView Class, from which QTreeView (and therefore QTableWidget too) inherits. You will use code including tableWidget->setEditTriggers(QAbstractItemView::AllEditTriggers); item->setFlags(item->flags() | Qt::ItemIsEditable); Those lines make an item editable by double-clicking (I think) on a cell. Ultimately you should use void QAbstractItemView::setItemDelegate(QAbstractItemDelegate *delegate). You should subclass your own QAbstractItemDelegate. Override its QWidget *QAbstractItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const. Have that return a new QComboBox for your case. Then the Qt infrastructure will be responsible for showing and destroying the combobox for you. Qt's Star Delegate Example provides editablity and shows what you need to do. There may be other examples. Ultimately you will be creating a QStyledItemDelegate and overriding its "editor" methods to return a combobox to use and populating that combo's items.
    • SOLVED Add QCheckBox in every cells of a column in QTable Widget
      General and Desktop • qtablewidget qcheckbox • • aim0d  

      3
      0
      Votes
      3
      Posts
      240
      Views

      @Christian-Ehrlicher Oh, so stupid of mine for not thinking about it ahha thanks! RESULT for future noobie like me: for(int row=0;row<=12;row++){ QHBoxLayout *a = new QHBoxLayout(); a->addWidget((new QCheckBox(""))); QWidget *z = new QWidget(); z->setLayout(a); ui->tableWidget->setCellWidget(row,0, z); }
    • SOLVED Does QTableWidget::setItem() automatically delete the previous object when it is called for the second time?
      General and Desktop • qtablewidget qt6 • • Zhmou  

      2
      0
      Votes
      2
      Posts
      99
      Views

      @Zhmou Because https://doc.qt.io/qt-6/qtablewidget.html#setItem says: The table takes ownership of the item. that means it owns it, and will dispose it if you replace it.
    • SOLVED updating a column rows (condition Barcode) using QMap<QString,Int>
      General and Desktop • qtablewidget qmap column updating • • Proton Phoenix  

      3
      0
      Votes
      3
      Posts
      126
      Views

      Thank You so much Bro You Are Life Save I wish All the best happy life for you <3 note : it works better than i ever imagine <3
    • SOLVED QTableWidget items Memory Leak Problem!
      General and Desktop • qtablewidget memory release row qabstractitemde • • Proton Phoenix  

      10
      0
      Votes
      10
      Posts
      433
      Views

      Just a note about a non-Valgrind, windows-specific leak-checking method: https://docs.microsoft.com/en-us/visualstudio/debugger/finding-memory-leaks-using-the-crt-library?view=vs-2019 It has been a while since I have done any extensive work on a Microsoft platform, but in my recollection crtdbg.h can do many helpful diagnostic things, although it is sometimes tricky to get all the debug build settings configured in the way that will trigger the features you seek.
    • UNSOLVED How to display QTableWidget selected row in a qLineEdit of the same class?
      General and Desktop • qtablewidget pyqt5 python3 setfoc • • CEO.  

      12
      0
      Votes
      12
      Posts
      636
      Views

      @CEO said in How to display QTableWidget selected row in a qLineEdit of the same class?: @JonB now I discovered you are either hoarding knowledge or might not have done any work on the question. Yes, you're right. I have nothing better to do than lie to questioners about what I know and they should do, and I don't spend enough of my time writing the code demanded to save them time. Here is an extract from my usage of the QDataWidgetMapper which I know nothing about from a sample project of mine. I'm sorry if my variables/widgets/model are not the same as yours. Also here I happen to be binding to QSpinBoxes, let me know if I need to change it to QLineEdits for you. void SectorRegisters::initDataWidgetMapper() { // set up the `QDataWidgetMapper` this->dwm = new QDataWidgetMapper(this); // set model (this->sectorsModel is the model being used, in my case it's a `QStandardItemModel`) SectorsModel *sectorsModel = this->sectorsModel; dwm->setModel(sectorsModel); // Vertical => widget mapped to row dwm->setOrientation(Qt::Vertical); // current index is always column #0 dwm->setCurrentIndex(0); // Region mappings dwm->addMapping(ui->spinRegionSocialState, SectorsModel::RegionSocialState); dwm->addMapping(ui->spinRegionGoodAreas, SectorsModel::RegionGoodAreas); dwm->addMapping(ui->spinRegionPoorAreas, SectorsModel::RegionPoorAreas); dwm->addMapping(ui->spinRegionCash, SectorsModel::RegionCash); // Here there are many further widget<->model-column mappings // ... } You're welcome.
    • SOLVED Auto line-break with QLabel within QTableWidget
      General and Desktop • qtablewidget qlabel qt 5 wordwrap • • silverfox  

      3
      0
      Votes
      3
      Posts
      580
      Views

      @ChrisW67 Thanks! It work like a charm. For the reason to why I was using QLabel, well I'm mostly testing for stuffs. I'll switch it up later.
    • UNSOLVED Signal and Slot with two different UI class in QT
      General and Desktop • qtablewidget signal & slot qt c++ • • Rhutu  

      2
      0
      Votes
      2
      Posts
      440
      Views

      @Rhutu Nothing should "vanish". If you overwrite what is in QTableWidget with something not as you intended then obviously it will cease to show whatever it showed before. If you need to pass additional data from your main window to the slot, you can either do it via a C++ lambda for the slot, or put a slot which is in the main window instead of Obj,SLOT(WriteToFile()), and have that call Obj->WriteToFile(extra). Stop using old-style SIGNAL/SLOT() macros for signals/slots, use https://wiki.qt.io/New_Signal_Slot_Syntax, it's better and it will help you connect correct things.
    • SOLVED Updating QTablWidget correctly
      General and Desktop • qwidget qtablewidget • • TUStudi  

      9
      0
      Votes
      9
      Posts
      362
      Views

      @TUStudi Well, it's not necessarily that: you can create an item via void QTableWidget::setItem(int row, int column, QTableWidgetItem *item) instead.
    • SOLVED scrollbar not reappearing when a tableWidget is stretched then shrinked
      General and Desktop • qtablewidget resize scrollbar • • torea  

      4
      0
      Votes
      4
      Posts
      395
      Views

      Calling the base class implementation did the trick. Thank you again! I didn't try the resizeToContents as some cells shouldn't be sized to their content in some context.
    • UNSOLVED Custom QCheckbox in QT widgets
      General and Desktop • stylesheet qtablewidget qtwidgets qcheckbox • • EagleSparrow  

      3
      0
      Votes
      3
      Posts
      382
      Views

      Here is the code. QList<SomeClass> ModeTableEntries ; for (int row = 0; row < ModeTableEntries .length(); row++) { ui->EntriesTableWidget->insertRow(row); ui->EntriesTableWidget->setRowHeight(row, 45); ModeValues value = ModeTableEntries [row]; QTableWidgetItem* currentItem = new QTableWidgetItem(value .ModeText); if(TestModeEnabled == true) currentItem->setCheckState(Qt::Checked); else currentItem->setCheckState(Qt::Unchecked); ui->EntriesTableWidget->setItem( row, 0, currentItem); currentItem->setFlags(currentItem->flags()^(Qt::ItemIsEditable )); } The problem is that I cannot style the default implementation of the QTableWidgetItem(QCheckbox) that is part of the QTableWidgetItem.
    • SOLVED What's the best way to use QTableWidgetItem(to don't waste space)
      General and Desktop • c++ qtablewidget for loop saving space • • Muhammad Mirab Br.  

      4
      0
      Votes
      4
      Posts
      287
      Views

      @Christian-Ehrlicher Alright, thanks!
    • SOLVED QTableWidget filling out whole QGroupBox
      General and Desktop • qwidget qtablewidget • • TUStudi  

      5
      0
      Votes
      5
      Posts
      400
      Views

      @mrjj That's it, thanks :)
    • UNSOLVED How to layout CChartViews in a table
      General and Desktop • qtablewidget qchart qchartview • • clayton_tx  

      2
      0
      Votes
      2
      Posts
      177
      Views

      Hi Well it could work but you will have the issue that a row can only be one height so if one big and the rest small, it will look odd. But if all chart will be ca same size yes it should work ok. Alternatively, you could tweak this https://doc.qt.io/qt-5/qtwidgets-layouts-flowlayout-example.html and put it into a QScrollArea. Add this to it https://wiki.qt.io/Widget-moveable-and-resizeable Tweak it a bit and it should allow for a group of chars in various sizes and scrollable.
    • UNSOLVED Deselection event for QTableWidgetItem
      General and Desktop • qtablewidget qtoolbar qtablewidgetit • • ArthurLodbrock  

      2
      0
      Votes
      2
      Posts
      178
      Views

      As I already wrote on SO use selectionChanged() / itemSelectionChanged() signals ... when nothing is selected, you can't deselect items so how do you want to achieve a deselect here?
    • SOLVED Hiding individual cells of QTableWidget
      General and Desktop • qtablewidget hide • • Muster Maxmann  

      6
      0
      Votes
      6
      Posts
      778
      Views

      Okay proxy and listView is what solved the problem for me, thanks @SGaist and @Christian-Ehrlicher. I made a QListView and filtered it with the input of a QLineEdit and a sortFilterProxy, then I toke the data of the sortFilter and inserted it into a QTableView and cleaned the presentation with a delegate up. It works fast and snappy with my 20 exmaple data, I just hope that it keeps working as good with my ~300 data, but to get to this tests I have to finish other parts of my project first. I call this solved for now :-)
    • SOLVED QTableWidget does not show values that come from a QMap
      General and Desktop • qtablewidget qmap • • SpaceToon  

      3
      0
      Votes
      3
      Posts
      308
      Views

      @SGaist Thank oyu, that worked!
    • UNSOLVED when i am trying to move table widget item its shaking all item??
      General and Desktop • qtablewidget drag and drop • • Himanshu charde  

      2
      0
      Votes
      2
      Posts
      162
      Views

      Hi, Can you explain what exactly you are trying to achieve ?
    • SOLVED QTableWidget's width behaves strangely when applying any CSS
      General and Desktop • qtablewidget css width • • SnuggleKat  

      6
      0
      Votes
      6
      Posts
      937
      Views

      @A-A-SEZEN said in QTableWidget's width behaves strangely when applying any CSS: Check QTableWidget font, before css and after. Just changed the font to Consolas. Anyways, adding ui->tableWidget_memory->horizontalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); to my code solved this problem.
    • UNSOLVED QTableWidget See difference between 0 and NULL
      General and Desktop • qtablewidget • • hobbyProgrammer  

      7
      0
      Votes
      7
      Posts
      353
      Views

      @hobbyProgrammer After fetching data from database, https://doc.qt.io/qt-5/qvariant.html#isNull or (if you are SQL) https://doc.qt.io/qt-5/qsqlfield.html#isNull is the thing to test.
    • SOLVED Detecting sort completed on QTableWidget
      General and Desktop • qtablewidget qt 5 sort • • james b-s  

      7
      0
      Votes
      7
      Posts
      537
      Views

      Thanks that worked
    • UNSOLVED How to check circular references in qtablewidget cells?
      General and Desktop • qtablewidget • • y_belikov  

      2
      0
      Votes
      2
      Posts
      148
      Views

      @y_belikov Well, follow the references until you reach the first cell (then you have circular references) or last cell without references. For the first case you actually should see whether you visit one cell more than once.
    • UNSOLVED QTableWidget/QTableView "word wrap" behavior, but without words (no spaces)?
      General and Desktop • qtableview qtablewidget wordwrap stretch new line • • oblivioncth  

      1
      0
      Votes
      1
      Posts
      1612
      Views

      No one has replied

    • UNSOLVED QTableWidget setCellWidget(QWidget*) Inconsistant Behavior with Cell Selection and Focus
      General and Desktop • qwidget qtablewidget qpushbutton • • Blanky  

      1
      0
      Votes
      1
      Posts
      951
      Views

      No one has replied

    • SOLVED Add Qlabel as item in QTableview
      General and Desktop • qtableview qtablewidget qlabel qstandarditem • • sayan275  

      3
      0
      Votes
      3
      Posts
      2565
      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!
    • UNSOLVED QTableWidget draw/Paint over widget in a cell ?
      General and Desktop • qwidget qtablewidget qpainter • • Dariusz  

      7
      0
      Votes
      7
      Posts
      2080
      Views

      You won't get a paint event at all during drag'n'drop I would guess since the cursor is not directly painted by Qt when I'm correct.
    • SOLVED QTableWidget - get column/row from under mouse ?
      General and Desktop • qtablewidget • • Dariusz  

      9
      0
      Votes
      9
      Posts
      3060
      Views

      Ok solved, Im gigantic NUB. I used itemAt instead of indexAt and took me a while to notice it... everything works! thanks!!!
    • UNSOLVED QTableWidgetItem set background color on click (over stylesheet )
      General and Desktop • stylesheet qtablewidget • • nevdokimof  

      15
      0
      Votes
      15
      Posts
      8601
      Views

      Delegate widget has to be used.
    • SOLVED Set QTableWidgetItem maximum displayed text length (truncate and add ellipsis if longer)
      General and Desktop • qtablewidget • • fugreh  

      3
      0
      Votes
      3
      Posts
      2387
      Views

      Thanks I ended up doing the simplest thing: QString descriptionText = QFontMetrics(table->font()).elidedText(m_description, Qt::ElideRight, uiSettings::descriptionTextWidth, 0); QTableWidgetItem *descriptionItem = new QTableWidgetItem(descriptionText); descriptionItem->setToolTip(m_description); table->setItem(r, 0, descriptionItem);
    • SOLVED QTableWidget: horizontal scroll bar not displayed
      General and Desktop • qtablewidget qt5.6.3 • • Alain38 0  

      2
      0
      Votes
      2
      Posts
      2070
      Views

      Forget my question. I have found the problem. It is not realted to QTableWidget. It just a problem with my QSS. In fact the scroll bar is present. But in "white on white"!
    • 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
      3378
      Views

      ok, the template solution is also working here. Thanks a lot for your help!
    • SOLVED send Qtable widget selected items to list widget upon button click
      General and Desktop • qtcreator qtablewidget push button listwidget • • Kushan  

      8
      0
      Votes
      8
      Posts
      3615
      Views

      For future reference, this approach only works if you know in advance all the roles you will use. You can use KSelectionProxyModel instead if you need a proper general implementation
    • UNSOLVED Getting changed values of a QTablewidget into a QStringList
      General and Desktop • qtcreator qtablewidget item change • • Kushan  

      8
      0
      Votes
      8
      Posts
      3909
      Views

      This is strange. could you try if this snippet works for you? #include <QApplication> #include <QWidget> #include <QVBoxLayout> #include <QPushButton> #include <QTableWidget> #include <QLabel> int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget mainWid; QStringList changedValues; QVBoxLayout* mainLay=new QVBoxLayout(&mainWid); QTableWidget* tableWidget = new QTableWidget(&mainWid); QPushButton* button = new QPushButton(QStringLiteral("Display list"),&mainWid); QLabel* resultLabel = new QLabel(&mainWid); mainLay->addWidget(tableWidget); mainLay->addWidget(button ); mainLay->addWidget(resultLabel ); tableWidget->setColumnCount(1); tableWidget->setRowCount(5); for(int i=0;i<5;i++){ QTableWidgetItem* const newItem= new QTableWidgetItem; newItem->setData(Qt::EditRole,i); tableWidget->setItem(i,0,newItem); } QObject::connect(tableWidget,&QTableWidget::cellChanged,[&changedValues,tableWidget](int row, int column)->void{changedValues<<tableWidget->item(row,column)->text();}); QObject::connect(button ,&QPushButton::clicked,[&changedValues,resultLabel ]()->void{resultLabel->setText(changedValues.join(','));}); mainWid.show(); return a.exec(); }
    • UNSOLVED Changing a QTableWidget rows based on the changes made to another QTableWidget rows
      General and Desktop • qtcreator qtablewidget index change • • Kushan  

      5
      0
      Votes
      5
      Posts
      1765
      Views

      Then even easier to use 1 QSqlQueryModel or QSqlTableModel
    • UNSOLVED Reindexing items in Tablewidgets
      General and Desktop • qtcreator qtablewidget edit reindex • • Kushan  

      4
      0
      Votes
      4
      Posts
      1066
      Views

      Sure you can, loop through the content of the left QTableWidget and update the content of the right table to match. But again, you seem to overcomplicate things.
    • SOLVED How to delete whole table in qtablewidget?
      General and Desktop • qtablewidget • • vasu_gupta  

      8
      0
      Votes
      8
      Posts
      12399
      Views

      @VRonin I love this. It helped a lot. Thanks.
    • UNSOLVED How to auto update table element with a structures element value??
      General and Desktop • qtablewidget • • vasu_gupta  

      2
      0
      Votes
      2
      Posts
      711
      Views

      Hi, How did you made your table ?