Results 1 to 8 of 8

Thread: QComboBox inside QTableWidget

  1. #1
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question QComboBox inside QTableWidget

    Hi to all
    I've a question;
    why in my QTableWidget with QComboBox cells I cannot use currentRow() function ?
    There is a special Selection modality to set?

    Thanks a lot
    Manuel

  2. #2
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QComboBox inside QTableWidget

    I want to be more precise:

    when I select the QComboBox "cell" in my TableWidget
    myTable->currentRow() returns me a 0xffffff value


  3. #3
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question QTableWidget::currentRow ()

    Hi to all,
    Why in my QTableWidget with a ComboBox cell the function QTableWidget::currentRow () doesn't work ???????

    the function returns the correct int value only if i select the other colums (QTableWidgetItems)

    Thanks in advance

    Manuel

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QComboBox inside QTableWidget

    Well, interacting directly with the combo box does not change the "current" item in the table (unless you do it programmatically).

  5. #5
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QComboBox inside QTableWidget

    But how i can do it ?

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QComboBox inside QTableWidget

    For example with an event filter..
    Install this for all cell widgets in you table:
    Qt Code:
    1. bool MyTableWidget::eventFilter(QObject *obj, QEvent *event)
    2. {
    3. if (event->type() == QEvent::FocusIn && obj->isWidgetType())
    4. {
    5. QWidget* widget = qobject_cast<QWidget*>(obj);
    6. if (widget)
    7. {
    8. QTableWidgetItem* item = itemAt(widget->pos());
    9. if (item)
    10. {
    11. setCurrentItem(item);
    12. }
    13. }
    14. }
    15. return QTableWidget::eventFilter(obj, event);
    16. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QComboBox inside QTableWidget

    Sorry but I haven't understood very well your example

    with this function i can analyze the object (for me is a certain cell ?) and an event, but which is the reason of that return (it's a recursive function ?)

    Sorry for my late answer
    Thanks
    Bye

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QComboBox inside QTableWidget

    Quote Originally Posted by campana
    Sorry but I haven't understood very well your example

    with this function i can analyze the object (for me is a certain cell ?) and an event, but which is the reason of that return (it's a recursive function ?)

    Sorry for my late answer
    Thanks
    Bye
    Unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

    http://doc.trolltech.com/4.1/qobject.html#eventFilter

Similar Threads

  1. Replies: 2
    Last Post: 5th June 2008, 22:32
  2. Again QTableWidget and QComboBox delegate
    By Aki-Matti in forum Qt Programming
    Replies: 2
    Last Post: 4th March 2008, 14:40
  3. QComboBox drop list button events
    By maird in forum Qt Programming
    Replies: 5
    Last Post: 20th October 2007, 20:25
  4. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2007, 00:29
  5. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 19:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.