QT z动态创建Qcombobox

Form1::Form1(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Form1)
{
    ui->setupUi(this);

    QComboBox * cbb_1 = new QComboBox(this);
    cbb_1->view()->setFixedWidth(100); //内容宽
//    cbb_1->setFixedWidth(100);//控件宽
    cbb_1->setGeometry(rect().x()+200, rect().y()+10,
                                100, 30);  //坐标 高 宽
    for(int i; i< 20; i++){
        cbb_1->addItem(QString::asprintf("Item %d",i));
    }




}

posted @ 2020-08-24 09:49  黑贝是条狗  阅读(704)  评论(0编辑  收藏  举报