首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

QT中的QListWidget遇到的有关问题

2013-12-23 
QT中的QListWidget遇到的问题如何是图中的QListWidget的宽度变大?代码如下所示ControlInterFace::ControlI

QT中的QListWidget遇到的问题
如何是图中的QListWidget的宽度变大?代码如下所示
QT中的QListWidget遇到的有关问题
ControlInterFace::ControlInterFace(QWidget *parent, Qt::WindowFlags f): QDialog(parent, f)
{
QFont font("ZYSong18030", 12); //设置字体
setFont(font);
setWindowTitle(tr("Welcome to LED workspace")); //设置标题
contentListWidget = new QListWidget(this); //可直接添加数据,用于提示用户操作
//contentListWidget->setGeometry(100, 2000, 300, 500); //这两种方法我都试过了,不行啊
//contentListWidget->resize(200, 500);
pointLabel = new QLabel(tr("WorkSpace"));
pointLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); //设置框架风格: 下陷的嵌板
clearPushButton = new QPushButton(this);
clearPushButton->setText(tr("Clear"));
clearPushButton->resize(10, 10);
changePushButton = new QPushButton(this);
changePushButton->setText(tr("Change"));
stringPushButton = new QPushButton(this);
stringPushButton->setText(tr("Code string"));
timePushButton = new QPushButton(this);
timePushButton->setText(tr("Data time"));
picPushButton = new QPushButton(this);
picPushButton->setText(tr("Pixel picture"));
statuePushButton = new QPushButton(this);
statuePushButton->setText(tr("Power statue"));
turnPushButton = new QPushButton(this);
turnPushButton->setText(tr("Turn power"));
brightPushButton = new QPushButton(this);
brightPushButton->setText(tr("Bright level"));
updatePushButton = new QPushButton(this);
updatePushButton->setText(tr("Update IP"));
exitPushButton = new QPushButton(this);
exitPushButton->setText(tr("Exit"));
bottomLabel = new QLabel;
bottomLabel->setText(tr("WangYiwei 3142731"));
QVBoxLayout *leftLayout = new QVBoxLayout;
leftLayout->addWidget(pointLabel);
leftLayout->addWidget(clearPushButton);
leftLayout->addWidget(changePushButton);
QHBoxLayout *topLayout = new QHBoxLayout;
topLayout->addLayout(leftLayout);
topLayout->addWidget(contentListWidget, 1, 0);
QGridLayout *grid = new QGridLayout;
grid->addWidget(stringPushButton, 0, 0);
grid->addWidget(timePushButton, 0, 1);
grid->addWidget(picPushButton, 0, 2);
grid->addWidget(statuePushButton, 0, 3);
grid->addWidget(turnPushButton, 1, 0);
grid->addWidget(brightPushButton, 1, 1);
grid->addWidget(updatePushButton, 1, 2);
grid->addWidget(exitPushButton, 1, 3);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin(10); //页边距
mainLayout->setSpacing(20); //行间距
mainLayout->addLayout(topLayout);
mainLayout->addLayout(grid);
mainLayout->addWidget(bottomLabel);
//设置布局管理器
setLayout(mainLayout);
}
[解决办法]
调整下margin,layout需要使用expending
[解决办法]
不太懂QT不过应该是设置其控件的某个属性。

实现自动绘制。

热点排行