qt 未整理

{
      setWindowFlags(Qt::FramelessWindowHint);//无边框窗体
//      QPalette pal = palette();
//      pal.setColor(QPalette::Foreground, QColor(0xff,0xff,0xff));
//      setPalette(pal);
//      setAttribute(Qt::WA_TranslucentBackground, true);
      Qt::WindowFlags flags = windowFlags();
      setWindowFlags(flags | Qt::WindowStaysOnTopHint);

//      setMouseTracking(true);


//    setWindowOpacity(0.5);
//     QPalette palette;
//     QColor color(190, 230, 250);
//     color.setAlphaF(0.9);
//     palette.setBrush(this->backgroundRole(), color);
//     setPalette(palette);
//     //如果这个QWidget直接show,是有背景色的,但是如果放到一个父Widget中时,它就没有了效果。添加如下代码后就可以了:
//     setAutoFillBackground(true);

//    closeButton = new QPushButton("X",this);
//    closeButton->setObjectName("closeButton");
//    closeButton->setGeometry(15,0,22,22);
//    QMetaObject::connectSlotsByName(this);
    resize(WIDGET_WEIGHT,WIDGET_HEIGHT);
    move (0,0);

//    setStyleSheet("background: transparent;");
//    QPixmap pixmap(":/images/cut.png");
    setPixmap(pixmap);
//    setMask(pixmap.mask());
    QBitmap bmp(this->size());
    bmp.fill();
    QPainter p(&bmp);
    p.setPen(Qt::NoPen);
    p.setBrush(Qt::black);
    p.drawRoundedRect(bmp.rect(),20,20);//画遮罩圆角
    setMask(bmp);//设置窗体遮罩
    QVBoxLayout * mainLayout = new QVBoxLayout;
    QHBoxLayout * titleLayout = new QHBoxLayout;
    QLabel * version = new QLabel(this);
    version->setText(QString("version 1.0 betal"));
    version->setFixedHeight(WIDGET_HEIGHT / (ShowLineNumbers + 2));
//    QPushButton * closeButton = new QPushButton(this);
//    closeButton->setIcon(QIcon(":/images/cut.png"));
//    connect(closeButton, SIGNAL(clicked(bool)), this, SLOT(closeWindow()));
//    closeButton->installEventFilter(this);
    titleLayout->addWidget(version);
//    titleLayout->addStretch(1);
//    titleLayout->addWidget(closeButton);
//    QLabel * label = new QLabel(this);
//    QPixmap pixmap(":/images/new.png");
//    QSize labelsize = pixmap.size();
//    qDebug("width = %d, height = %d", labelsize.width(), labelsize.height());
//    label->setPixmap(pixmap);
    label->setPixmap(pixmap.scaled(labelsize.width()/ 2, labelsize.height()/2));
//    titleLayout->addWidget(label);
    QVBoxLayout * vlayout = new QVBoxLayout;
    QString str;
    for(int i = 0; i <</SPAN> listLabelText.size(); i++)
    {
        str = listLabelText[i];
        CMyLabel * label = new CMyLabel(str);
        listLabel.push_back(label);
        if(i <</SPAN> ShowLineNumbers)
        {
            CMyLabel * newlable = new CMyLabel(str);
            if(0 == i)
            {
                newlable->setEnterColor();
                enterPos = 0;
                enterVecPos = 0;
            }
            newlable->setFixedHeight(WIDGET_HEIGHT / (ShowLineNumbers + 2));
            qDebug("WIDGET_HEIGHT / (ShowLineNumbers + 2) = %d", WIDGET_HEIGHT / (ShowLineNumbers + 2));
            listShowLabel.push_back(newlable);
//            newlable->installEventFilter(this);
            vlayout->addWidget(newlable);
        }
    }
//    vlayout->setSpacing(0);
//    titleLayout->setSpacing(0);
//    mainLayout->setContentsMargins(0,0,0,0);
//    mainLayout->setSpacing(0);
//    titleLayout->setMargin(0);
//    vlayout->setMargin(0);
//    mainLayout->setMargin(0);
//    mainLayout->setContentsMargins(0,0,0,0);
    mainLayout->addStretch(1);
    mainLayout->addLayout(titleLayout);
    mainLayout->addStretch(2);
    qDebug("vlayout->spacing() =%d", vlayout->spacing());
    vlayout->setSpacing(0);
    mainLayout->addLayout(vlayout);
    mainLayout->addStretch(1);
    qDebug("mainLayout->spacing() =%d", mainLayout->spacing());
    mainLayout->setSpacing(0);
    mainLayout->setMargin(0);
    qDebug("mainLayout->setSpacing()");
    setLayout(mainLayout);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值