Results 1 to 3 of 3

Thread: Qtablewidget make rows not selectable

  1. #1
    Join Date
    Sep 2011
    Posts
    51
    Thanks
    2
    Qt products
    Qt4

    Default Qtablewidget make rows not selectable

    Good morning,
    i've a QTablewidget, 2 cols, 3 rows.

    i use :

    mytable->setSelectionBehavior(QAbstractItemView::SelectRow s); //to select a row
    mytable->setSelectionMode(QAbstractItemView::SingleSelecti on); //to have single selection.

    All well,
    now i want to disable the onclick selection, when a row is empty, (so the row background color remains unchanged, and no empty row is porcessed)

    How can i disable the oncick selection for a certain row ?

    Thanks Gabriele

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Qtablewidget make rows not selectable

    Qt Code:
    1. //On each item of the empty row you need to call
    2. QTableWidgetItem::setFlags(Qt::NoItemFlags);
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Sep 2011
    Posts
    51
    Thanks
    2
    Qt products
    Qt4

    Default Re: Qtablewidget make rows not selectable

    Thank you for your answer...it brings me in the right direction...
    Unfortunately i use old QT 4.2.3 and this flag does not exist.
    i use setFlags(Qt::ItemIsEditable)...this works and the line is not selectable..
    but problems remains...the row is not selectable but the values is passed.
    I've a button..and when i clicks..the value is passed even if the row seems to be unselectable...
    Last edited by gab74; 5th December 2011 at 14:13.

Similar Threads

  1. Drag & Drop rows in a QTableWidget
    By vycke in forum Qt Programming
    Replies: 7
    Last Post: 19th January 2012, 01:01
  2. Deselecting Rows in a QTableWidget
    By Sarol in forum Newbie
    Replies: 1
    Last Post: 27th July 2011, 00:47
  3. QTableWidget set value of many rows in One Step
    By sagirahmed in forum Newbie
    Replies: 3
    Last Post: 11th October 2010, 07:08
  4. Replies: 1
    Last Post: 10th June 2010, 18:22
  5. How to set rows of QtableWidget to the same height?
    By sawerset in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2008, 19:09

Tags for this Thread

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.