Results 1 to 8 of 8

Thread: Spreadsheet of QCheckBoxes...help!

  1. #1
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Spreadsheet of QCheckBoxes...help!

    Hello all,

    I have just been told to program a spreadsheet looking area of checkboxes, each cell in the spread sheet being a checkbox.

    The axis of the spreadsheet (rows) is the a unique object and the other axis (columns) are properties that can be turned on for each object. When a user clicks on a object name, all the properties for the object should be selected or unselected. If the user clicks on a property name then all the check boxes for each object should have that property selected or unselected....

    Any ideas of how I should approach the problem?

    Cheers,

    Jonathan

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Spreadsheet of QCheckBoxes...help!

    Maybe you could use QTableView/QTreeView and a custom model with checkable items?

  3. #3
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Spreadsheet of QCheckBoxes...help!

    from what I can see so far....you can set cells selected, but you can't set the cell to be a widget....they need to be of type QTableWidgetItem or did I miss something?

    how would you implement this "custom model"?

    thanks

    Jonathan

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Spreadsheet of QCheckBoxes...help!

    What about QTableWidget::setCellWidget( int row, int col, QWidget* widget )?

    Regards

  5. The following user says thank you to marcel for this useful post:

    JonathanForQT4 (11th July 2007)

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Spreadsheet of QCheckBoxes...help!

    Quote Originally Posted by JonathanForQT4 View Post
    how would you implement this "custom model"?
    You will have to subclass QAbstractTableModel and implement few methods. Everything is described here:

    A checkbox will appear if Qt::ItemIsUserCheckable flag is set for the given cell.

  7. #6
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Spreadsheet of QCheckBoxes...help!

    jacek: I am very lost with this implementation....I would have to define row and column count to return the number of rows and columns?

    since I didn't understand jacek's implementation I have gone ahead with marcel's.....the only thing I can quite get is, when I select a header, which selects all the column (or row)....which signal do I connect to one of my slots which goes through and selects all the qcheckboxes? I can't seem to find a signal that works for mass selection of the cells...only for single selection of the cell through double or single clicking.


    cheers,

    Jonathan

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Spreadsheet of QCheckBoxes...help!

    Quote Originally Posted by JonathanForQT4 View Post
    I would have to define row and column count to return the number of rows and columns?
    Yes.

    Quote Originally Posted by JonathanForQT4 View Post
    which signal do I connect to one of my slots which goes through and selects all the qcheckboxes?
    Check QItemSelectionModel and QHeaderView classes. You can get pointers to their instances through QTableView methods.

  9. The following user says thank you to jacek for this useful post:

    JonathanForQT4 (11th July 2007)

  10. #8
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Spreadsheet of QCheckBoxes...help!

    thanks guys, got everything working nicely

Similar Threads

  1. Problem with custom widget
    By jnana in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2006, 11:55
  2. scrolling like a spreadsheet
    By Honestmath in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2006, 16: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.