Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:如何使用QListWidget和QListWidgetItem

From Wiki
Jump to: navigation, search

Archived.png存档: 这篇文章是存档,因为考虑到今天它与第三方开发者建立商业解决方案不相关。

Widgets deprecated and whole page out of date with respect to site links etc.

Article Metadata

兼容于
平台:
Symbian

文章
dougcn 在 15 Mar 2009 创建
最后由 hamishwillee 在 14 Feb 2014 编辑
  • 适用平台:S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
  • 运行设备: Qt Creator IDE & S60 Emulator
  • 关键字:web browser in Qt,QWebView,QToolBar,QStatusBar


Contents

简介

这是一个演示QListWidget和QListWidgetItem用法的程序。用这两个类我们可以在listwidget中创建一个简单的列表。

Qt Creator IDE 及 Qt SDK

兼容性

  • 源代码与Qt 兼容
  • 此源代码可以在Carbide C++中开发并运行

各种函数

  • 若这个属性为true,就启用了列表排序;若为false,则禁止排序。缺省值为false。
 listWidget->setSortingEnabled(1);

源代码

#include <QtGui/QApplication>
#include "listwidgetdialog.h"
#include<QWidget>
#include<QHBoxLayout>
#include<QListWidget>
#include<QListWidgetItem>
#include<QObject>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
 
QWidget *win=new QWidget();
QHBoxLayout *lay=new QHBoxLayout();
QListWidget *listWidget = new QListWidget();
listWidget->setSortingEnabled(1);
QListWidgetItem *lst1 =new QListWidgetItem("Oak", listWidget);
QListWidgetItem *lst2 =new QListWidgetItem("Banana", listWidget);
QListWidgetItem *lst3 =new QListWidgetItem("Apple", listWidget);
QListWidgetItem *lst4 =new QListWidgetItem("Orange", listWidget);
QListWidgetItem *lst5 =new QListWidgetItem("Grapes", listWidget);
QListWidgetItem *lst6 =new QListWidgetItem("Jayesh", listWidget);
QListWidgetItem *lst7 =new QListWidgetItem("Pineapple", listWidget);
QListWidgetItem *lst8 =new QListWidgetItem("GROUNDNUT", listWidget);
QListWidgetItem *lst9 =new QListWidgetItem("Sugarcane", listWidget);
QListWidgetItem *lst10 =new QListWidgetItem("Coconut", listWidget);
QListWidgetItem *lst11 =new QListWidgetItem("Remote", listWidget);
QListWidgetItem *lst12 =new QListWidgetItem("Mango", listWidget);
listWidget->insertItem(1,lst1);
listWidget->insertItem(2,lst2);
listWidget->insertItem(3,lst3);
listWidget->insertItem(4,lst4);
listWidget->insertItem(5,lst5);
listWidget->insertItem(6,lst6);
listWidget->insertItem(7,lst7);
listWidget->insertItem(8,lst8);
listWidget->insertItem(9,lst9);
listWidget->insertItem(10,lst10);
listWidget->insertItem(11,lst11);
listWidget->show();
lay->addWidget(listWidget);
win->setLayout(lay);
win->show();
 
return a.exec();
}


屏幕截图

Listwidget.JPG

内部链接

How to use QListWidget and QListWidgetItem

This page was last modified on 14 February 2014, at 03:36.
451 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×