Results 1 to 3 of 3

Thread: connecting CheckBox inside QTableWidget with a function

  1. #1
    Join Date
    May 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default connecting CheckBox inside QTableWidget with a function

    Hi,

    i have a QGraphicsItem that i want to be hidden or shown, due to its checkmark which i want to place inside a TableWidget. What i have so far:

    Qt Code:
    1. QTableWidget *table = new QTableWidget(8,3);
    2. item->data(Qt::CheckStateRole);
    3. item->setCeckState(Qt::Checked);
    4. table->setItem(3,0,item);
    To copy to clipboard, switch view to plain text mode 

    ... which creates a wonderful CheckBox inside my table. But how can i link the check mark state to my GraphicsItem?
    I tried several signals provided by the QTableWidget class, but some of the ones i tried produced a compiler error stating, that this signal doesn't exist. And the others that work, don't seem to be appropriate for my problem.

    Thanks in advance!
    Last edited by jpn; 23rd May 2008 at 10:36. Reason: missing [code] tags

  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: connecting CheckBox inside QTableWidget with a function

    Quote Originally Posted by Merkura View Post
    But how can i link the check mark state to my GraphicsItem?
    I tried several signals provided by the QTableWidget class, but some of the ones i tried produced a compiler error stating, that this signal doesn't exist. And the others that work, don't seem to be appropriate for my problem.
    QTableWidget::itemChanged() is the closest you can get with available signals. You just have to keep in mind that it gets emitted whenever any item data changes, not just check state. A signal like checkStateChanged() has been requested but unfortunately Trolltech rejected the idea. See also QxtTableWidget.
    J-P Nurmi

  3. #3
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connecting CheckBox inside QTableWidget with a function

    You can set the pointer to your graphics item in the QTableWidgetItem (setData()), then use the QTableWidget signal itemClicked(QTableWidgetItem* item) & see if it's in the right column, or data() != NULL, or some other way to validate that it's one of your checkbox items. Then you can use the pointer to show/hide as needed.

    Vycke

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.