- 
UID:121526 
 
- 
- 注册时间2011-08-30
 
- 最后登录2017-09-14
 
- 在线时间19小时
 
 
 
- 
- 发帖4
 
- 搜Ta的帖子
 
- 精华0
 
- 金钱40
 - 威望14
 - 贡献值0
 - 好评度4
 
 
 
- 
访问TA的空间加好友用道具
 
 
 
 
 
 
  
 
 | 
 
 
一个七寸屏上的嵌入式程序,其中有个功能是点击 按钮读取 文件并生成一个QTableWidget,因为耗时较长,所以想做一个弹出 窗口提示正在读取 数据。但奇怪的是这个窗口初始化时隐藏后无论如何都不再 显示。跪求高人解答!!   - #include "ResultWidget.h"
 - #include <QDialog>
 - #include <time.h>
 - #include <windows.h>
 - //
 - //@@
 - //
 - ResultWidget::ResultWidget(QWidget *parent) :
 -     QWidget(parent)
 - {
 -     //
 -     //
 -     this->InitUI();
 -     //
 -     //
 -     this->CreateConnect();
 - }
 - //
 - //@@
 - //
 - ResultWidget::~ResultWidget()
 - {
 -     //
 - }
 - //
 - //@@
 - //
 - void ResultWidget::InitUI(void)
 - {
 -     //
 -     //
 -     QFont font;
 -     font.setFamily(QString::fromUtf8("WenQuanYi Zen Hei"));
 -     font.setPointSize(36);
 -     font.setBold(false);
 -     font.setWeight(50);
 -     //
 -     //
 -     this->resize(800, 390);
 -     this->setMinimumSize(QSize(800, 390));
 -     this->setMaximumSize(QSize(800, 390));
 -     //
 -     //
 -     TestObjLabel = new QLabel(this);
 -     TestObjLabel->setObjectName(QString::fromUtf8("TestObjLabel"));
 -     TestObjLabel->setFont(font);
 -     TestObjLabel->setText(QString(QObject::tr("测试主机: 机车信号主机")));
 -     //
 -     //
 -     TestPlugLabel = new QLabel(this);
 -     TestPlugLabel->setObjectName(QString::fromUtf8("TestPlugLabel"));
 -     TestPlugLabel->setFont(font);
 -     TestPlugLabel->setText(QString(QObject::tr("测试插头:X30")));
 -     //
 -     //
 -     TestTimeLabel = new QLabel(this);
 -     TestTimeLabel->setObjectName(QString::fromUtf8("TestTimeLabel"));
 -     TestTimeLabel->setFont(font);
 -     TestTimeLabel->setText(QString(QObject::tr("测试时间:2012年7月12日 12:45:32")));
 -     //
 -     //
 -     TestUnitLabel = new QLabel(this);
 -     TestUnitLabel->setObjectName(QString::fromUtf8("TestUnitLabel"));
 -     TestUnitLabel->setFont(font);
 -     TestUnitLabel->setText(QString(QObject::tr("数据单位:兆欧")));
 -     //
 -     //
 -     ListWidget = new QTableWidget(this);
 -     ListWidget->setFont(font);
 -     ListWidget->setContextMenuPolicy(Qt::DefaultContextMenu);
 -     ListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
 -     //
 -     //
 -     QWidget *verticalLayoutWidget = new QWidget(this);
 -     verticalLayoutWidget->setObjectName(QString::fromUtf8("verticalLayoutWidget"));
 -     verticalLayoutWidget->setGeometry(QRect(10, 10, 781, 341));
 -     //
 -     //
 -     verticalLayout = new QVBoxLayout(verticalLayoutWidget);
 -     verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
 -     verticalLayout->setContentsMargins(0, 0, 0, 0);
 -     verticalLayout->addWidget(TestObjLabel);
 -     verticalLayout->addWidget(TestPlugLabel);
 -     verticalLayout->addWidget(TestTimeLabel);
 -     verticalLayout->addWidget(TestUnitLabel);
 -     verticalLayout->addWidget(ListWidget);
 -     //
 -     //
 -     ReturnPBtn = new QPushButton(this);
 -     ReturnPBtn->setObjectName(QString::fromUtf8("ReturnPBtn"));
 -     ReturnPBtn->setGeometry(QRect(315, 352, 75, 31));
 -     ReturnPBtn->setFont(font);
 -     //
 -     //
 -     ShowDetailPBtn = new QPushButton(this);
 -     ShowDetailPBtn->setObjectName(QString::fromUtf8("ShowDetailPBtn"));
 -     ShowDetailPBtn->setGeometry(QRect(410, 352, 75, 31));
 -     ShowDetailPBtn->setFont(font);
 -     //
 -     //
 -     //
 -     //@@就是这个widget
 -     //
 -     HintMsgWidget = new QWidget(this);
 - //    HintMsgWidget->setWindowFlags(Qt::Popup);
 -     HintMsgWidget->setFont(font);
 -     HintMsgWidget->setStyleSheet("color:white; background-color:blue");
 -     HintMsgWidget->setGeometry(QRect(200, 30, 400, 240));
 -     HintMsgWidget->hide();
 -     //
 -     //
 -     HintMsg1Label = new QLabel(HintMsgWidget);
 -     HintMsg1Label->setObjectName(QString::fromUtf8("HintMsg1Label"));
 -     HintMsg1Label->setFont(font);
 -     HintMsg1Label->setGeometry(0, 0, 400, 120);
 -     HintMsg1Label->setAlignment(Qt::AlignCenter);
 -     HintMsg1Label->setText(QString(QObject::tr("正在读取数据......")));
 -     //
 -     //
 -     HintMsg2Label = new QLabel(HintMsgWidget);
 -     HintMsg2Label->setObjectName(QString::fromUtf8("HintMsg2Label"));
 -     HintMsg2Label->setFont(font);
 -     HintMsg2Label->setGeometry(0, 120, 400, 120);
 -     HintMsg2Label->setAlignment(Qt::AlignCenter);
 -     HintMsg2Label->setText(QString(QObject::tr("请稍候....")));
 -     //
 -     //
 -     //
 -     //
 -     this->ShowResultList();
 - }
 - //
 - //@@
 - //
 - void ResultWidget::CreateConnect(void)
 - {
 -     //
 -     //
 -     connect(this->ReturnPBtn, SIGNAL(clicked()), this, SLOT(PBtnClickedSlot()));
 -     connect(this->ShowDetailPBtn, SIGNAL(clicked()), this, SLOT(PBtnClickedSlot()));
 - }
 - //
 - //@@
 - //
 - void ResultWidget::ShowResultList(void)
 - {
 -     //
 -     //
 -     m_ResultShowType = ShowList;
 -     //
 -     //
 -     this->TestObjLabel->hide();
 -     this->TestPlugLabel->hide();
 -     this->TestTimeLabel->hide();
 -     this->TestUnitLabel->hide();
 -     //
 -     this->ShowDetailPBtn->show();
 - }
 - //
 - //@@
 - //
 - void ResultWidget::ShowResultDetail(void)
 - {
 -     //
 -     //
 -     m_ResultShowType = ShowDetail;
 -     //
 -     //
 -     this->TestObjLabel->show();
 -     this->TestPlugLabel->show();
 -     this->TestTimeLabel->show();
 -     this->TestUnitLabel->show();
 -     //
 -     this->ShowDetailPBtn->hide();
 - }
 - //
 - //@@
 - //
 - void ResultWidget::PBtnClickedSlot(void)
 - {
 -     //
 -     //
 -     QPushButton *ClickedPBtn = qobject_cast<QPushButton*>(sender());
 -     //
 -     //
 -     if (ClickedPBtn->objectName() == "ReturnPBtn")
 -     {
 -         //
 -         if (m_ResultShowType == ShowList)
 -         {
 -             //
 -             emit ChangeWidgetSignal(0);
 -         }
 -         else
 -         {
 -             //
 -             m_ResultShowType = ShowList;
 -             //
 -             this->ShowResultList();
 -         }
 -     }
 -     else if (ClickedPBtn->objectName() == "ShowDetailPBtn")
 -     {
 -         //
 -         m_ResultShowType = ShowDetail;
 -         //
 -         //
 -         //@@在这里显示,然后等待两秒,然后隐藏
 -         //
 -         HintMsgWidget->show();
 -         HintMsgWidget->raise();
 -         //
 -         //
 -         this->ShowResultDetail();
 -         //
 -         //
 -         Sleep(2000);
 -         //
 -         //
 -         this->HintMsgWidget->hide();
 -     }
 -     else
 -     {
 -         //
 -         m_ResultShowType = ShowList;
 -         //
 -         emit ChangeWidgetSignal(0);
 -     }
 - }
 
  
 
 
 |