Beispiel #1
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWidget window;

    QLabel* title = new QLabel("Custom widgets on a QListWidget");
    title->setAlignment(Qt::AlignHCenter);

    QListWidget* list = new QListWidget;
    list->addItem("foo");


    for (int i = 0; i < 5; i++){
        QListWidgetItem* item;
        item = new QListWidgetItem(list);
        list->addItem(item);
//        QPushButton* button = new QPushButton("hey");
        Form *f = new Form;
        item->setSizeHint(f->minimumSizeHint());
        list->setItemWidget(item, f);
    }
    list->addItem("bar");

    QVBoxLayout* layout = new QVBoxLayout(&window);
    layout->addWidget(title);
    layout->addWidget(list);
    window.setLayout(layout);

    window.show();

    return a.exec();
}
QGroupBox *UOptionsDialog::createMessagesBox()
{
	QGroupBox *messagesBox = new QGroupBox(tr("Messages"), this);
	QVBoxLayout *topBoxLayout = new QVBoxLayout(messagesBox);

	QListWidget *listWidget = new QListWidget(messagesBox);

	QListWidgetItem *item = new QListWidgetItem(listWidget);

	listWidget->addItem(item);
	listWidget->setItemWidget(item, new UMessageWidget(listWidget));
	topBoxLayout->addWidget(listWidget);
//	QHBoxLayout *regularMessageGroup = new QHBoxLayout(messagesBox);

//	_showRegularMessageCheckbox = new QCheckBox(tr("Show this message:"),
//		messagesBox);
//	_showRegularMessageCheckbox->setChecked(
//		USettingsManager::sharedManager()->showRegularMessage());
//	regularMessageGroup->addWidget(_showRegularMessageCheckbox);

//	_regularMessageText = new QLineEdit(messagesBox);
//	_regularMessageText->setText(
//		USettingsManager::sharedManager()->regularMessageText());
//	regularMessageGroup->addWidget(_regularMessageText);

//	regularMessageGroup->addWidget(new QLabel(tr("every:"), this));

//	_regularMessageTime = new QTimeEdit(this);
//	_regularMessageTime->setTime(
//		USettingsManager::sharedManager()->regularMessageTime());
//	regularMessageGroup->addWidget(_regularMessageTime);

//	topBoxLayout->addLayout(regularMessageGroup);

	messagesBox->setLayout(topBoxLayout);
	return messagesBox;
}