Results 1 to 6 of 6

Thread: QTableWidget cell clicked

  1. #1
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableWidget cell clicked

    I need to activate a slot when the 0, 0 cell of My table is clicked.
    I tried to use
    Qt Code:
    1. connect(table, SIGNAL(cellClicked(int,int)), this, SLOT(previousWeek()));
    To copy to clipboard, switch view to plain text mode 
    But it doesn't specify what cell needs to be clicked, so the slot is activated when any cell is clicked.
    I also tried to specify the cellClicked(int,int) as cellClicked(0,0), but then i get a warning:
    No such signal QTableWidget::cellClicked(0,0)

    How do i solve this problem?

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget cell clicked

    Qt Code:
    1. connect(table, SIGNAL(cellClicked(int,int)), this, SLOT(previousWeek(int,int)));
    2.  
    3. void YourClass::previousWeek(int row,int col)
    4. {
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 

    Joh

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

    Archa4 (6th April 2011)

  4. #3
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget cell clicked

    Thanks!
    I just solved this myself in same way

    Another question - how to make items not editable (i mean disable the edit on double click)?

  5. #4
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget cell clicked

    Just have a look at a sibling post of yours I have been answering today:

    http://www.qtcentre.org/threads/4036...lating-a-Table

    HIH

    Johannes

  6. The following user says thank you to JohannesMunk for this useful post:

    Archa4 (6th April 2011)

  7. #5
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget cell clicked

    Thanks again!
    Just read that one, but i choose:
    Qt Code:
    1. item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
    To copy to clipboard, switch view to plain text mode 

    Could i get in trouble using that?

  8. #6
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget cell clicked

    No, I don't think that will get you in any trouble. It just seems rather 'unstraightforward' to positively specify flags, where what your code really wants to achieve is disable a specific one. In terms of code readability..

    Joh

Similar Threads

  1. qtablewidget cell's x() , y()
    By BalaQT in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2010, 12:23
  2. Replies: 1
    Last Post: 19th May 2010, 15:10
  3. Replies: 1
    Last Post: 7th December 2009, 18:56
  4. Replies: 1
    Last Post: 21st April 2008, 22:43
  5. How can I get the value of the clicked cell in a QListView
    By murari2002 in forum Qt Programming
    Replies: 2
    Last Post: 27th September 2007, 17:18

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.