查看完整版本: [-- 关于布局的蛋疼问题,求助!!! --]

QTCN开发网 -> 其它技术开发讨论区 -> 关于布局的蛋疼问题,求助!!! [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

调味料来了 2014-03-28 21:36

关于布局的蛋疼问题,求助!!!

    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 2014-03-28 23:26
好好排一下版吧。论坛可以发代码模式。


查看完整版本: [-- 关于布局的蛋疼问题,求助!!! --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled