Common QT tableview settings

Source: Internet
Author: User

 

Qtableview is quite complicated.
Qtableview is a view that displays the table format.
Table = new qtableview; its frequently used functions include:
1. display the grid table-> setshowgrid (false );
2. Adjust the column table by content-> resizecolumnstocontents ();
3. Get the vertical header table-> verticalheader (); of course, there is a horizontal header.
4. Set the non-editing status vtable-> setedittriggers (qtableview: noedittriggers); 5. Set the selection method and select the row verticalview-> setselectionbehavior (qtableview: selectrows );
6. model object

Qstandarditemmodel
* Model = newqstandarditemmodel;

 model->setColumnCount(4);
 model->setHeaderData(0,Qt::Horizontal,tr("File"));
 model->setHeaderData(1,Qt::Horizontal,tr("Path"));
 model->setHeaderData(2,Qt::Horizontal,tr("Size"));
 model->setHeaderData(3,Qt::Horizontal,tr("Duration"));

Set the display model to 4 columns
7. Add item to model qstandarditem * Item1 =
New qstandarditem (TR ("yesterdayonce
More. Mid "));

 QStandardItem* item2 = new QStandardItem(tr("C://Mid//"));
 QStandardItem* item3 = new QStandardItem(tr("0.001M"));
 QStandardItem* item4 = new QStandardItem(tr("3:48"));
 QList<QStandardItem*> item;
 item << item1 << item2 << item3 << item4;
Model-> appendrow (item); 8. Set the model to viewsetmodel (model );

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.