📄 8_2.cpp
字号:
#include <qapplication.h>#include <qwidget.h>#include <qlistview.h>class MyMainWindow:public QWidget{ public: MyMainWindow(); private: QListView *listview; QListViewItem *topic1; QListViewItem *topic2; QListViewItem *topic3; QListViewItem *item;};MyMainWindow::MyMainWindow(){ setGeometry(100,100,300,300); listview = new QListView(this); listview->setGeometry(0,0,400,400); listview->setRootIsDecorated(true); listview->addColumn("Book"); listview->addColumn("Solid Copies"); listview->addColumn("Price"); topic1 = new QListViewItem(listview,"Topic 1"); topic2 = new QListViewItem(listview,"Topic 2"); topic3 = new QListViewItem(listview,"Topic 3"); item = new QListViewItem(topic1,"Book 1","21,000","$29.99"); item = new QListViewItem(topic2,"Book 2","19,000","$24.99"); item = new QListViewItem(topic3,"Book 3","14,000","$99.99"); item = new QListViewItem(topic3,"Book 1","3800,000","$29.99"); item = new QListViewItem(topic3,"Book 2","16,000","$24.99"); item = new QListViewItem(topic3,"Book 3","9,000","$99.99"); item = new QListViewItem(topic3,"Book 1","3800,000","$29.99"); item = new QListViewItem(topic3,"Book 2","16,000","$24.99"); item = new QListViewItem(topic3,"Book 3","9,000","$99.99");}main(int argc,char **argv){ QApplication a(argc,argv); MyMainWindow w; a.setMainWidget(&w); w.show(); a.exec();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -