乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Qt文檔閱讀筆記-stackUnder官方解析與實(shí)例

       勤奮不止 2019-06-25

      目錄

      官方解析

      博主例子


      官方解析

      這里可以配合raise()和lower()這兩個(gè)函數(shù)來使用!

       

      博主例子

      用2個(gè)label,點(diǎn)擊誰誰就浮在界面的最上面,很簡(jiǎn)單的代碼,程序運(yùn)行截圖如下:

      源碼如下:

      widget.h

      #ifndef WIDGET_H
      #define WIDGET_H
      
      #include <QWidget>
      
      QT_BEGIN_NAMESPACE
      class QLabel;
      QT_END_NAMESPACE
      
      namespace Ui {
      class Widget;
      }
      
      class Widget : public QWidget
      {
          Q_OBJECT
      
      public:
          explicit Widget(QWidget *parent = 0);
          void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
          ~Widget();
      
      private:
          Ui::Widget *ui;
      
          bool m_otherWidget;
          QList<QLabel*> m_list;
      };
      
      #endif // WIDGET_H
      

      widget.cpp

      #include "widget.h"
      #include "ui_widget.h"
      
      #include <QLabel>
      #include <QMouseEvent>
      #include <QDebug>
      
      Widget::Widget(QWidget *parent) :
          QWidget(parent),
          ui(new Ui::Widget)
      {
          ui->setupUi(this);
      
          m_otherWidget = false;
          QLabel *label1 = new QLabel(this);
          label1->setText("  label 1");
          label1->setGeometry(60, 60, 160, 110);
          label1->setStyleSheet("background-color: rgb(0,0,0); color: rgb(255,0,0);");
          label1->stackUnder(this);
      
      
          QLabel *label2 = new QLabel(this);
          label2->setGeometry(50, 50, 150, 100);
          label2->setText("  label 2");
          label2->setStyleSheet("background-color: rgb(0,255,255); color: rgb(255,0,0);");
          label2->stackUnder(this);
      
          label1->raise();
          label2->raise();
          qDebug()<<this->children();
          m_list<<label1;
          m_list<<label2;
      }
      
      void Widget::mouseReleaseEvent(QMouseEvent *event)
      {
          if(event->button() == Qt::LeftButton){
              if(m_otherWidget){
                  m_list[0]->raise();
      
              }
              else{
                  m_list[1]->raise();
              }
              m_otherWidget = !m_otherWidget;
              event->accept();
              this->update();
          }
      }
      
      Widget::~Widget()
      {
          delete ui;
      }
      

      main.cpp

      #include "widget.h"
      #include <QApplication>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          Widget w;
          w.show();
      
          return a.exec();
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多