Results 1 to 10 of 10

Thread: Making Table cell as a combobox?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Making Table cell as a combobox?

    I have implemented data as

    Qt Code:
    1. QVariant className::data(const QModelIndex & index, int role) const
    2. {
    3. if( index.isValid() == false )
    4. return QVariant();
    5.  
    6. if( role == Qt::EditRole )
    7. {
    8. if( index.internalPointer() )
    9. {
    10. int parentRow = ipToRow(index.internalPointer());
    11. return QString("Cell %3.%1.%2").arg(index.row()).arg(index.column())
    12. .arg(parentRow);
    13. }
    14.  
    15. return QString("Cell %1.%2").arg(index.row()).arg(index.column());
    16. }
    To copy to clipboard, switch view to plain text mode 

    and Flags() as
    Qt Code:
    1. Qt::ItemFlags className::flags( const QModelIndex& idx ) const
    2. {
    3.  
    4. return Qt::ItemIsEditable;
    5. }
    To copy to clipboard, switch view to plain text mode 
    but it did not work.

    did i do something wrong...?

  2. #2
    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: Making Table cell as a combobox?

    Quote Originally Posted by kaushal_gaurav View Post
    Qt Code:
    1. Qt::ItemFlags className::flags( const QModelIndex& idx ) const
    2. {
    3.  
    4. return Qt::ItemIsEditable;
    5. }
    To copy to clipboard, switch view to plain text mode 
    This would mean that all items are disabled, thus non-editable. Try something like:
    Qt Code:
    1. Qt::ItemFlags className::flags(const QModelIndex &index) const
    2. {
    3. if (!index.isValid())
    4. return 0;
    5.  
    6. return Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable;
    7. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Making Table cell as a combobox?

    yipeee....it works...
    thanks buddy..

    but how can make it persistent....i have to click the table cell to make it show.

  4. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    520
    Thanks
    13
    Thanked 77 Times in 75 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Making Table cell as a combobox?


Similar Threads

  1. Replies: 2
    Last Post: 18th March 2008, 15:38
  2. Replies: 4
    Last Post: 4th February 2008, 06:16
  3. Replies: 11
    Last Post: 7th September 2006, 23:15
  4. table with combobox cells
    By mgurbuz in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2006, 12:12
  5. Highlighting the border of cell in Table
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 21st March 2006, 08:20

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
  •  
Qt is a trademark of The Qt Company.