Results 1 to 3 of 3

Thread: checkboxes

  1. #1
    Join Date
    Jan 2008
    Location
    Vancouver, Canada
    Posts
    54
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default checkboxes

    Below is some code that puts a check box in the first colum of a TableWidget. They are entered nicely in the column, but I have two questions:

    Qt Code:
    1. for (int i = 0; i < list.size(); ++i)
    2. {
    3. fileTable->setRowCount(j+1);
    4. QCheckBox *inserter = new QCheckBox();
    5. fileTable->setCellWidget(j,0,inserter);
    6. }
    To copy to clipboard, switch view to plain text mode 

    1st, how do I align the check boxes to the centre, the only thing i see is for text.

    2nd (and more important), I'm not sure how to acces these now. I want to connect them, so that when one is checked, it sends a signal like:

    connect( checkbox , SIGNAL( toggeled(bool) ), this, SLOT( getType() ) );

    What do I put for checkbox, above? It was created when another signal was called to populate the table.... I'm not sure if I'm being clear.

  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: checkboxes

    The item view framework supports checkable items out of the box. Take a look at QTableWidgetItem::setFlags(). I highly recommend to avoid flooding the table full of item widgets.
    Qt Code:
    1. item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    abrou (4th February 2008)

  4. #3
    Join Date
    Jan 2008
    Location
    Vancouver, Canada
    Posts
    54
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: checkboxes

    Thanks for the advice. I actually changed what I was going to do, since only two were going to be selected at a time, I thought maybe drag and drop would be better for the user. It seems to be working, although I'm not sure if I'm doing it the best way. Anyway, thanks!

Similar Threads

  1. Checkboxes: check and uncheck
    By 3nc31 in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2008, 21:26
  2. Checkboxes in QAbstractITemModel
    By Valheru in forum Qt Programming
    Replies: 5
    Last Post: 28th November 2007, 20:23
  3. strange extra spacing between checkboxes
    By jamadagni in forum Qt Programming
    Replies: 1
    Last Post: 19th November 2007, 10:13
  4. Checkboxes in menu items
    By markcole in forum Qt Programming
    Replies: 2
    Last Post: 4th June 2007, 15:16
  5. Displaying windows depending on checkboxes
    By Salazaar in forum Newbie
    Replies: 1
    Last Post: 12th May 2007, 19:42

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.