当我单击 MainWindow 的按钮时,我正在使用 QProgressBar 创建新窗口,但是在创建新窗口时,在填充周期工作时不会出现 QProgressBar。之后 QProgressBar 出现并被填充。
构造函数:
ProgressWin::ProgressWin():QWidget()
{
this->resize(273,98);
this->move(670, 430);
bar1 = new QProgressBar(this);
bar1->setGeometry(20, 31, 251, 31);
bar1->setMinimum(0);
bar1->setMaximum(10000);
this->show();
unsigned long long secr, PQ;
unsigned long long rv;
unsigned long long decr;
for(int v = 0; v <= 100000; v++) {
bar1->setValue(v);
}
}
调用新窗口的按钮代码:
void RsaMainWindow::ButtClickCrypt()
{
FileName1 = ui->LineCrypt->text();
if(FileName1.isEmpty()) {
QMessageBox::information(0, "Information", "File for Crypt wasn't chosen");
return;
}
NewWin = new ProgressWin;
}
新窗口类:
class ProgressWin : public QWidget
{
QProgressBar *bar1;
public:
ProgressWin();
};
主窗口类:
[namespace Ui {
class RsaMainWindow;
}
class RsaMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit RsaMainWindow(QWidget *parent = 0);
~RsaMainWindow();
private slots:
void ButtClickViewCryp();
void ButtClickViewDecr();
void ButtClickViewKeys();
void ButtClickCrypt();
void ButtClickDecr();
private:
Ui::RsaMainWindow *ui;
QString FileName1;
QString FileName2;
QString FileName3;
ProgressWin *NewWin;
};][1]