1 QStandardItemModel* model = static_cast<QStandardItemModel*>(ui->combobox->view()->model()); 2 if(model) 3 { 4 for(int i = 0; i < model->rowCount(); i ++) 5 { 6 if(model->item(i)) 7 model->item(i)->setTextAlignment(Qt::AlignCenter); 8 } 9 }
标签:居中,setTextAlignment,Qt,QCombobox,item,model From: https://www.cnblogs.com/ybqjymy/p/17749001.html