人乳奶水videos喷奶水,亚洲一区二区三区在线观看成人av,成人影,久久久蜜臀国产一区二区,免费观看一区,麻豆xxxhd

QT界面設計

首頁 > 公司事務2023-04-01 11:55:25

八、利用Qt 圖形界面,設計一個倒計時時鐘,顯示剩余的秒數(最大99秒),顯示到0為止,要求

八、利用Qt 圖形界面,設計一個倒計時時鐘,顯示剩余的秒數(最大99秒),顯示到0為止,要求n(1)能夠設置倒計時的時長;n(2)能夠設置放大字體,字體大小為40;n(3)能夠設置改字體的顏色及背景顏色;

建議你這樣試試看:

#ifndef QWAITTINGDIALOG_H

#define QWAITTINGDIALOG_H

 

#include <QDialog>

#include <QLabel>

#include <QThread>

#include <QTimer>

 

class QWaittingDialog : public QDialog

{

    Q_OBJECT

public:

    explicit QWaittingDialog(QWidget *parent = nullptr);

 

    void Run(int nStartValue);

 

signals:

 

public slots:

    void on_timer_timeout();

 

private:

    QLabel*             m_pLabel;

    QTimer*             m_pTimer;

    int                 m_nStartValue;

 

 

    // QWidget interface

protected:

    void paintEvent(QPaintEvent* event);

};

 

 

#endif // QWAITTINGDIALOG_H

#include "QWaittingDialog.h"

#include <QPainter>

#include <QVBoxLayout>

 

QWaittingDialog::QWaittingDialog(QWidget *parent) : QDialog(parent)

    , m_nStartValue(0)

{

    setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint);

 

    // 全透明

    setAttribute(Qt::WA_TranslucentBackground);

 

    QVBoxLayout* pVBoxLayout = new QVBoxLayout(this);

 

    m_pLabel = new QLabel();

    pVBoxLayout->addWidget(m_pLabel);

 

    m_pLabel->setText("");

    m_pLabel->setAlignment(Qt::AlignCenter);

 

    QString strStyle = "QLabel{"

                       "font-family: \"Microsoft YaHei\";"

                       "font-size: 128px;"

                       "color: rgb(50, 50, 50, 180);"

                       "}";

 

    m_pLabel->setStyleSheet(strStyle);

 

    m_pTimer = new QTimer(this);

    connect(m_pTimer, &QTimer::timeout, this, &QWaittingDialog::on_timer_timeout);

    m_pTimer->setInterval(1000);

}

 

void QWaittingDialog::Run(int nStartValue)

{

    m_pTimer->stop();

 

    m_nStartValue = nStartValue;

 

    QWidget* parent = parentWidget();

    move(parent->pos());

    resize(parent->rect().width(), parent->rect().height());

 

    on_timer_timeout();

    m_pTimer->start();

 

    show();

}

 

void QWaittingDialog::on_timer_timeout()

{

    if (m_nStartValue == 0)

    {

        m_pTimer->stop();

        close();

        return;

    }

 

    m_pLabel->setText(QString::number(m_nStartValue));

 

    m_nStartValue--;

}

 

 

 

void QWaittingDialog::paintEvent(QPaintEvent* event)

{

    // 避免鼠標穿透

    QPainter painter(this);

    painter.fillRect(this->rect(), QColor(240, 240, 240, 1));   // 配合全透明屬性一起使用

}


這樣做的好處:

注意事項:

熱死

絕對不行還想不想你小雞雞什么驚喜就等你繼續繼續那些你抽煙到哪巴西亞婦女節嘲笑你現金皆大歡喜經濟系獨具匠心就像你說的啊啊啊啊吧

看看酷兔兔
學會拒絕不錯發個股海護航發發發

pycharm中使用Qt Designer實現UI界面設計

確保pyqt 、qt designer已正常安裝
Pycharm中setting->Tools->External Tools->+

如下:

working directory:一般會自動生成 或者輸入

即當前目錄
然后就可以在tool下發現 pyqt designer了

打開界面如下 就可以開始頁面設計了

用designer生成的文件為.ui文件,我們需要轉換成py文件,所以要用到PyUIC,配置過程類似

program:這里是你python.exe文件的位置。
arguments:這里固定的

working directory:這里注意不要用自動生成的路徑 需要使用

不然在生成py文件時會報錯 no such file *.ui

這樣就可以直接生成.py文件了。
新建一個base.py文件

運行base.py 即可打開你寫好的頁面

如何用 Qt 做出酷炫的界面

首先你需要一個美工,幫你設計好看的UI樣式,或者自己設計也可以,

然后參照設計好的UI樣式,完成代碼的編寫,在設置代碼樣式前你需要知道這些控件的設置方法,比如一個QPushButton的背景色:紅色,前景設置白色,邊框黑色

QPushButton#evilButton {
    background-color: red;/* 背景色 */
    border-style: outset;
    border-width: 2px;
    border-color: black;/* 邊框色 */
    color: white; /* 文字顏色 */
}

其他控件配置請參考Qt提供的幫助文檔:

http://doc.qt.io/qt-4.8/stylesheet-examples.html

相關推薦:

離婚個稅問題(離婚個稅子女扣除爭議)

申請破產怎樣賠償(公司破產后如何賠付員工)

公司詐騙罪的賠償(公司被詐騙 我應該承擔賠償責任嗎)

破產怎樣拿到賠償(公司破產后員工如何獲得賠償)

企業合并程序是怎樣的(企業合并的程序是怎樣的)