Results 1 to 4 of 4

Thread: set column as not editable in Qtablewidget

  1. #1
    Join Date
    Jul 2012
    Location
    Chennai , India
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default set column as not editable in Qtablewidget

    connect(ui->widget,SIGNAL(cellDoubleClicked(int,int)),this,SL OT(column_check(int,int)));


    void Saleorder::column_check(int row,int column)
    {
    QTableWidgetItem* itemtot=ui->widget->item(row, 9);

    if( column == 9 )
    {
    if (itemtot && !itemtot->text().isEmpty())
    {
    itemtot->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled );
    }

    }
    }
    i tried this but the program is crashed.

    Any one help me solve the problem.

    Is there is any other way to achieve to make the entire column as not editable

    Thanks in advance

  2. #2
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Cool Re: set column as not editable in Qtablewidget

    Qt Code:
    1. tableWidgetItem->setFlags(tableWidgetItem->flags() & (~Qt::ItemIsEditable));
    To copy to clipboard, switch view to plain text mode 

    Remove your signal-slot code.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  3. #3
    Join Date
    Jul 2012
    Location
    Chennai , India
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: set column as not editable in Qtablewidget

    I used another way

    Qt::ItemFlags Saleorder::flags( const QModelIndex &index) const
    {
    Qt::ItemFlags flags = QSqlTableModel::flags(index);
    if (index.column() == 9 )
    flags &= ~Qt::ItemIsEditable;
    return flags;
    }


    But i need to know.how can i call this method

  4. #4
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: set column as not editable in Qtablewidget

    calling by the method name. I think you dont know the concept of c++.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

Similar Threads

  1. QTableWidget, one column editable
    By stella1016 in forum Qt Programming
    Replies: 5
    Last Post: 11th July 2012, 09:35
  2. Set an editable column for QTableView
    By SIFE in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2012, 23:09
  3. Column Not Editable
    By waynew in forum Qt Programming
    Replies: 1
    Last Post: 1st August 2010, 01:43
  4. Setting one* column of QTreeView to be editable
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 18th October 2006, 20:31
  5. Editable QListView Column ??
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2006, 18:55

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
  •  
Qt is a trademark of The Qt Company.