QTableWidget and QComboBox, issues when changing the QComboBox content
Hi there,
I’ve added a QComboBox inside a QTableWidget, I need to process data every time this QComboBox content changes. There are a lot of these QComboBox in the QTableWidget.
What I have done so far:
- Used the QTableWidget SIGNALS, without success. Seems like they properly work only on QTableWidgetItems.
- Tried to connect the editTextChanged SIGNAL, worked but I need to know the row of the item. When I change the content using MouseWheel for example the table’s current row does not change. The content of these QComboBox may be the same, so I can’t search.
- Tried to install the event filter, but none seems to work when I confirm a new index for the QComboBox.
- Added a property to each of these dynamic items with their row position, helped on the event filter, but I had to disable the ordination system.
I’ll try to sync all of what I’ve done to make it work.
Does anyone know a better way to do this?
5 replies
I used setCellWidget.
What is this setTableWidget? I couldn’t find any reference for it. (with a fast google search)
I haven’t used this class QStyledItemDelegate yet, your idea sounds interesting. Is there any example that you could show me?
A temporary solution that I’ve managed is to use setCurrentCell when the QEvent::FocusIn event is filtered.
Thanks for your answer!
I used setCellWidget. What is this setTableWidget? I couldn’t find any reference for it. (with a fast google search)
Sorry, I meant setCellWidget :-)
I haven’t used this class QStyledItemDelegate yet, your idea sounds interesting. Is there any example that you could show me?
You can have a look at the description of Model-View [doc.qt.nokia.com] or at the examples of Model-View [doc.qt.nokia.com] or the SpinBox Delegate example [doc.qt.nokia.com]
The examples always use a view class but the QTableWidget is a derived class of QTableView, so the delegates will also work there
I tried to use the Model View system to make it work, but it gave me more headaches than solutions.
QTableView::setModel is private so I couldn’t make it work with the table I had.
Now it is working, what I’ve done? Filtered the QEvent::FocusIn to force the Cell selection, here goes the code:
- {
- {
- if(widget)
- {
- ui->table->setCurrentCell(widget->pos().y() / 30, 0);
- }
- }
- return false;
- }
I’m using that stupid way to select the cell because it was not working with “the proper way”. The cells height are constant so a temporary solution for a short on time project.
I’m glad this is working, but I found what I’ve considered an error, maybe from Qt.
I created a topic to discuss it: link [developer.qt.nokia.com].
You must log in to post a reply. Not a member yet? Register here!


