QT 网格布局问题,在网格中动态添加按钮,但行与行间的距离太大了,这整个部分,是被这两行平均分配了
这个是我在MainWidget.cpp中功能实现代码QSqlQueryquery;query.exec("select*fromroom");intcount=-1,ro...
这个是我在MainWidget.cpp中功能实现代码
QSqlQuery query;
query.exec("select * from room");
int count = -1,rows = -1,col = -1;
while(query.next()) {
count++;col++;
QString nameValue = query.value(1).toString();//
QString IDValue = query.value(0).toString();//
QString Status = query.value(2).toString();//
QPushButton * button = new QPushButton(IDValue+"\n"+nameValue);
if(count%5 == 0)
{
rows++; col = 0;
}
button->setFont(QFont("Timer", 10, QFont::DemiBold));
ui->gridLayout->addWidget(button,rows,col,Qt::AlignTop);
}
我的gridlayout是在tablewidget内的 展开
QSqlQuery query;
query.exec("select * from room");
int count = -1,rows = -1,col = -1;
while(query.next()) {
count++;col++;
QString nameValue = query.value(1).toString();//
QString IDValue = query.value(0).toString();//
QString Status = query.value(2).toString();//
QPushButton * button = new QPushButton(IDValue+"\n"+nameValue);
if(count%5 == 0)
{
rows++; col = 0;
}
button->setFont(QFont("Timer", 10, QFont::DemiBold));
ui->gridLayout->addWidget(button,rows,col,Qt::AlignTop);
}
我的gridlayout是在tablewidget内的 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询