Results 1 to 3 of 3

Thread: qAbstractItemView, QAbstractItemModel...

  1. #1
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default qAbstractItemView, QAbstractItemModel...

    Hi,

    I have an array, with strings, and I'd like to create a QTableView with all that data.

    The problem cames when I start to dive inside the documentation... I need to call SetModel(), then I need to create a QAbstractItemModel, ok; but then I'll surely need QModelIndex... and now I don't know how continue.

    But, anyway, seems too complicated, there must be easier ways to do it. I just want to fill a table with strings...

    I'd like to use QTableWidget, way easier with all this stuff. but the user can click and edit the info and I can't allow that. Trying to find a method or something to set "clickable" to false but it doesn't seem to exist. :S

    How I can do it?

    thanks...

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qAbstractItemView, QAbstractItemModel...

    use QTableWidget. take a look at QTableWidgetItem::setFlags and Qt::ItemIsEditable flag.
    and also take a look at QAbstractItemView::NoEditTriggers.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. The following user says thank you to spirit for this useful post:

    jano_alex_es (18th May 2009)

  4. #3
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: qAbstractItemView, QAbstractItemModel...

    thanks! that was exactly what I was looking for

    with

    Qt Code:
    1. newItem->setFlags(Qt::ItemIsSelectable);
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. void CAddGroup::on_my_table_widget_cellClicked(int iRow,int iColumns)
    2. {
    3. ui.my_table_widget->selectRow(iRow);
    4. }
    To copy to clipboard, switch view to plain text mode 

    I have exactly what I needed (didn't select anything when clicking the item after setting up the flag, so I had to do it manually)

Similar Threads

  1. How to make QAbstractItemModel 's data checkable
    By nifei in forum Qt Programming
    Replies: 12
    Last Post: 1st April 2013, 19:52
  2. Replies: 2
    Last Post: 26th February 2009, 10:12
  3. QAbstractItemModel with rowSpan?
    By joeld42 in forum Qt Programming
    Replies: 0
    Last Post: 4th February 2009, 18:53
  4. Subclassing QAbstractItemView
    By psih128 in forum Qt Programming
    Replies: 4
    Last Post: 13th October 2008, 07:32
  5. setContentsMargins in QAbstractItemView
    By Promethee in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2006, 14:40

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.