ColorNamesDialog::ColorNamesDialog(QWidget *parent)
: QDialog(parent)
{
sourceModel = new QStringListModel(this);
sourceModel->setStringList(QColor::colorNames());
proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(sourceModel);
proxyModel->setFilterKeyColumn(0);
listView = new QListView;
listView->setModel(proxyModel);
listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
filterLabel = new QLabel(tr("&Filter:"));
filterLineEdit = new QLineEdit;
filterLabel->setBuddy(filterLineEdit);
syntaxLabel = new QLabel(tr("&Pattern syntax:"));
syntaxComboBox = new QComboBox;
syntaxComboBox->addItem(tr("Regular expression"), QRegExp::RegExp);
syntaxComboBox->addItem(tr("Wildcard"), QRegExp::Wildcard);
syntaxComboBox->addItem(tr("Fixed string"), QRegExp::FixedString);
syntaxLabel->setBuddy(syntaxComboBox);
connect(filterLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(reapplyFilter()));
connect(syntaxComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(reapplyFilter()));
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(listView, 0, 0, 1, 2);
mainLayout->addWidget(filterLabel, 1, 0);
mainLayout->addWidget(filterLineEdit, 1, 1);
mainLayout->addWidget(syntaxLabel, 2, 0);
mainLayout->addWidget(syntaxComboBox, 2, 1);
setLayout(mainLayout);
setWindowTitle(tr("Color Names"));
}
有些new出来的比如syntaxComboBox 没有delete掉,也没有指定parent。是不是 mainLayout->addWidget(filterLineEdit, 1, 1);之后 filterLineEdit就成了mainLayout的child了?
还有就是 QT,release出来的还是挺大的,没多少东西就好几兆,(跟MFC相比大很多),占得内存也占很多,这是为什么...
[ 此帖被czhouwang在2010-04-28 10:30重新编辑 ]