コード例 #1
0
IconSizeDialog::IconSizeDialog(const QString &caption, const QString &message, const QString &icon, int iconSize, QWidget *parent)
        : QDialog(parent)
{
    // QDialog options
    setWindowTitle(caption);

    QWidget *mainWidget = new QWidget(this);
    QVBoxLayout *mainLayout = new QVBoxLayout;
    setLayout(mainLayout);
    mainLayout->addWidget(mainWidget);

    setModal(true);

    QWidget *page = new QWidget(this);
    QVBoxLayout *topLayout = new QVBoxLayout(page);

    QLabel *label = new QLabel(message, page);
    topLayout->addWidget(label);

    QListWidget *iconView = new UndraggableKIconView(page);

    m_size16  = new QListWidgetItem(DesktopIcon(icon, 16), i18n("16 by 16 pixels"), iconView);
    m_size22  = new QListWidgetItem(DesktopIcon(icon, 22), i18n("22 by 22 pixels"), iconView);
    m_size32  = new QListWidgetItem(DesktopIcon(icon, 32), i18n("32 by 32 pixels"), iconView);
    m_size48  = new QListWidgetItem(DesktopIcon(icon, 48), i18n("48 by 48 pixels"), iconView);
    m_size64  = new QListWidgetItem(DesktopIcon(icon, 64), i18n("64 by 64 pixels"), iconView);
    m_size128 = new QListWidgetItem(DesktopIcon(icon, 128), i18n("128 by 128 pixels"), iconView);
    iconView->setIconSize(QSize(128, 128));
    iconView->setMinimumSize(QSize(128*6 + (6 + 2) * iconView->spacing() + 20, m_size128->sizeHint().height() + 2 * iconView->spacing() + 20));
    topLayout->addWidget(iconView);
    switch (iconSize) {
    case 16:  m_size16->setSelected(true); m_iconSize = 16;  break;
    case 22:  m_size22->setSelected(true); m_iconSize = 22;  break;
    default:
    case 32:  m_size32->setSelected(true); m_iconSize = 32;  break;
    case 48:  m_size48->setSelected(true); m_iconSize = 48;  break;
    case 64:  m_size64->setSelected(true); m_iconSize = 64;  break;
    case 128: m_size128->setSelected(true); m_iconSize = 128; break;
    }

    connect(iconView, SIGNAL(executed(QListWidgetItem*)),      this, SLOT(choose(QListWidgetItem*)));
    connect(iconView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(choose(QListWidgetItem*)));
    connect(iconView, SIGNAL(itemSelectionChanged()),          this, SLOT(slotSelectionChanged()));

    mainLayout->addWidget(page);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this);
    okButton = buttonBox->button(QDialogButtonBox::Ok);
    okButton->setDefault(true);
    okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    mainLayout->addWidget(buttonBox);
    connect(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), SLOT(slotCancel()));
}
コード例 #2
0
ファイル: monthly_care_plan.hpp プロジェクト: kumagi/qttry
	monthly_care_plan(QWidget* parent):QWidget(parent){
		if (parent->objectName().isEmpty()){
			parent->setObjectName(QString::fromUtf8("monthly_care_plan"));
		}
		parent->resize(800, 480);
		
		QSplitter splitter(Qt::Horizontal);
		
		verticalLayoutWidget = new QWidget(parent);
		verticalLayoutWidget->setObjectName(QString::fromUtf8("verticalLayoutWidget"));
		verticalLayoutWidget->setGeometry(QRect(0, 0, 160, 480));
		verticalLayoutWidget->setMinimumSize(160,480);
		verticalLayout = new QVBoxLayout(verticalLayoutWidget);
		verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
		verticalLayout->setContentsMargins(0, 0, 0, 0);
		care_plan_label = new QLabel(verticalLayoutWidget);
		care_plan_label->setObjectName(QString::fromUtf8("care_plan_label"));
		QFont font;
		font.setPointSize(14);
		care_plan_label->setFont(font);
		care_plan_label->setAlignment(Qt::AlignCenter);

		verticalLayout->addWidget(care_plan_label);

		human_list = new QListWidget(verticalLayoutWidget);
		human_list->setObjectName(QString::fromUtf8("human_list"));
		human_list->setMinimumSize(161,440);
		human_list->setMouseTracking(false);
		human_list->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

		verticalLayout->addWidget(human_list);

		human_widget = new one_human(this);
		human_widget->setGeometry(161, 0, 800-160, 480);

		this->retranslateUi(parent);

		QMetaObject::connectSlotsByName(parent);
		this->setMinimumSize(300,480);
	}