QT under Tablewidget in order to make a single column can not edit what to do?

Source: Internet
Author: User

QT under Tablewidget in order to make a column can not be edited what to do??? It is best to use a button control to control2012-03-31 19:57 Nanshan Poplar | Category: Other programming Languages | browse 2,658 times Share to: 2012-04-01 16:29The questioner is adopted byEnthusiastic netizens
Modify the column of the item's flags. For example:

#include <QApplication>
#include <QTableWidget>
#include <QTableWidgetItem>
int main (int argc, char **argv)
{
Qapplication app (argc, argv);
int col = 0;
Qtablewidget *table = new Qtablewidget (5, 3);
Table->setitem (0, col, New Qtablewidgetitem (QString ("Test"));
int i;
for (i = 0; i < Table->rowcount (); i++) {
Qtablewidgetitem *item = Table->item (i, COL);
if (item) {
Item->setflags (Item->flags () & (~qt::itemiseditable));
} else {
item = new Qtablewidgetitem;
Item->setflags (Item->flags () & (~qt::itemiseditable));
Table->setitem (i, col, item);
}
}
Table->show ();
return App.exec ();
}

QT under Tablewidget in order to make a single column can not edit what to do?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.