<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] ## 封裝彈窗 封裝基類 ``` class CustomDialog : public QDialog { public: explicit CustomDialog(QWidget *parent = nullptr) : QDialog(parent) { setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); setupUI(); } void setTitle(const QString &title) { m_titleLabel->setText(title); } void setBody(QLayout *bodyWidget) { m_bodyWidget = bodyWidget; m_mainLayout->addLayout(m_bodyWidget); } protected: void paintEvent(QPaintEvent *event) override { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); // 繪制陰影 QColor shadowColor(0, 0, 0, 10); for (int i = 0; i < 5; i++) { painter.setPen(Qt::NoPen); painter.setBrush(shadowColor); painter.drawRoundedRect(5 + i, 5 + i, width() - 10 - i * 3, height() - 10 - i * 3, 15, 15); shadowColor.setAlpha(shadowColor.alpha() - 1); } // 繪制主體 painter.setPen(Qt::NoPen); painter.setBrush(QColor(255, 255, 255)); painter.drawRoundedRect(10, 10, width() - 20, height() - 20, 15, 15); QDialog::paintEvent(event); } private: QLabel *m_titleLabel; QLayout *m_bodyWidget; QVBoxLayout *m_mainLayout; QPushButton *m_closeButton; void setupUI() { m_mainLayout = new QVBoxLayout(this); m_mainLayout->setContentsMargins(15, 15, 15, 15); m_titleLabel = new QLabel(this); m_titleLabel->setAlignment(Qt::AlignCenter); m_titleLabel->setStyleSheet("font-weight: bold; font-size: 16px; color: #333;"); m_closeButton = new QPushButton("×", this); m_closeButton->setFixedSize(30, 30); m_closeButton->setStyleSheet("QPushButton { border: none; font-size: 20px; color: #666; }" "QPushButton:hover { color: #f00; }"); QHBoxLayout *titleLayout = new QHBoxLayout(); titleLayout->addWidget(m_titleLabel); titleLayout->addWidget(m_closeButton); m_mainLayout->addLayout(titleLayout); connect(m_closeButton, &QPushButton::clicked, this, &QDialog::accept); setFixedSize(400, 300); // 默認大小,可以根據需要調整 } }; ``` 自定義彈窗 ``` class DemoDialog : public CustomDialog{ public: DemoDialog(QWidget *parent = nullptr):CustomDialog(parent) { this->setTitle(QString("adasdad title")) ; this->setBody(this->handleBody()) ; } QLayout * handleBody(){ QVBoxLayout * layout = new QVBoxLayout() ; layout->addWidget(new QLabel("adasdad body")) ; return layout; } }; ``` 使用彈窗 ``` DemoDialog dialog; dialog.exec(); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看