• 3917阅读
  • 1回复

[提问]关于布局的蛋疼问题,求助!!! [复制链接]

上一主题 下一主题
 

只看楼主 倒序阅读 楼主  发表于: 2014-03-28
    for(int i = 0;i<10;i++){        MaxWidget = new QWidget;        QHBoxLayout * Hbox_1 = new QHBoxLayout;        QLabel * lab = new QLabel;//头像        Hbox_1->setAlignment(Qt::AlignVCenter);        lab->setMaximumWidth(40);        lab->setStyleSheet("background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #5B5F5F, stop: 0.5 #0C2436,stop: 1.0 #27405A);  border:1px solid black;");        QVBoxLayout * Vbox_1 = new QVBoxLayout;        QHBoxLayout * HbSjMz = new QHBoxLayout;        QLabel * sj = new QLabel("14:30");        sj->setMaximumWidth(40);        sj->setMinimumHeight(25);        QLabel * mz = new QLabel(QStringLiteral("Qt 设计师"));        HbSjMz->addWidget(mz);        HbSjMz->addWidget(sj);        QLabel * msg = new QLabel(QStringLiteral("哈哈"));        sj->setAttribute(Qt::WA_TranslucentBackground);        mz->setAttribute(Qt::WA_TranslucentBackground);        msg->setAttribute(Qt::WA_TranslucentBackground);        Vbox_1->addLayout(HbSjMz);        Vbox_1->addWidget(msg);        msg->setMinimumHeight(25);        Hbox_1->addWidget(lab);
        Hbox_1->addLayout(Vbox_1);
        MaxWidget->setLayout(Hbox_1);        MaxWidget->setMaximumSize(400,50);        QLabel * line = new QLabel;        line->setStyleSheet("background: #444444");        line->setMinimumHeight(1);        line->setMaximumHeight(1);        ui->verticalLayout->addWidget(MaxWidget);        ui->verticalLayout->addWidget(line);        ui->verticalLayout->setMargin(0);
        MaxWidget->setStyleSheet("background-color:transparent");        MaxWidget->installEventFilter(this);        Vbox_1->setSpacing(0);        HbSjMz->setSpacing(0);
    }    ui->verticalLayout->setAlignment(Qt::AlignVCenter);    ui->verticalLayout->addStretch();//弹簧为什么我widget里面的lab (头像) 不能居中显示。。。。
离线realfan

只看该作者 1楼 发表于: 2014-03-28
好好排一下版吧。论坛可以发代码模式。
快速回复
限100 字节
 
上一个 下一个