3

カスタムウィンドウクラスがあります

#define NAME_WIDTH 150
#define NAME_HEIGHT 20

ObjectWindow::ObjectWindow(QWidget * parent)
{

}

void ObjectWindow::SetKey(KeyObject * keyObj)
{
    QGridLayout * layout = new QGridLayout(this);

    nameField = new QTextEdit(this);
    nameField->setText(keyObj->name);
    nameField->setGeometry(nameField->geometry().x(), nameField->geometry().y(),
                         NAME_WIDTH, NAME_HEIGHT);
    layout->addWidget(nameField);

    QHBoxLayout * picsLayout = new QHBoxLayout(this);
    for(std::vector<ImageInstance*>::iterator imgObj = keyObj->images.begin(); imgObj != keyObj->images.end(); imgObj++)
    {
        QComboBox * folderList = new QComboBox;
        picsLayout->addWidget(folderList);

        QImage image((*imgObj)->imgPath);
        QLabel * picLabel = new QLabel;
        picLabel->setPixmap(QPixmap::fromImage(image).scaled(200, 200, Qt::KeepAspectRatio, Qt::SmoothTransformation));
        picsLayout->addWidget(picLabel);
    }
    layout->addLayout(picsLayout, 2, 0);


    QPushButton * saveBtn = new QPushButton(this);
    saveBtn->setText("Save");
    connect(saveBtn, SIGNAL(released()),this, SLOT(Save()));
    layout->addWidget(saveBtn);

    setLayout(layout);
}

私が必要なのは

  • 名前を設定するための小さなテキスト フィールド。SetGeometry が機能しない理由がわかりません。

  • 各画像の上のドロップダウン リスト。画像とリストのセットごとに QHVertical レイアウトを作成できますが、もっと簡単な方法はないでしょうか?

ここに画像の説明を入力

4

1 に答える 1