combo.h
#ifndef CHART_H
#define CHART_H
#include <QDialog>
namespace Ui {
class Chart;
}
class Chart : public QDialog
{
Q_OBJECT
public:
explicit Chart(QWidget *parent = 0);
~Chart();
private slots:
void on_pushButton_clicked();
private:
Ui::Chart *ui;
};
#endif // CHART_H
combo.cpp
#include "chart.h"
#include "ui_chart.h"
#include <QMessageBox>
Chart::Chart(QWidget *parent) :
QDialog(parent),
ui(new Ui::Chart)
{
ui->setupUi(this);
ui->comboBox->addItem("aaa");
ui->comboBox->addItem("bbb");
}
Chart::~Chart()
{
delete ui;
}
void Chart::on_pushButton_clicked(){ /* QMessageBox msg; msg.setText("are you quit"); //给提示框增加按钮,增加Yes和No按钮 msg.setStandardButtons(QMessageBox::Yes|QMessageBox::No); //让弹出来的提示框暂停 if(msg.exec() == QMessageBox::Yes) { //关闭当前窗口 this->close(); } */ QMessageBox msg; msg.setText(ui->comboBox->currentText()); msg.exec(); /*msg.setStandardButtons(QMessageBox::Yes|QMessageBox::No); if(msg.exec() == QMessageBox::Yes) { QMessageBox::information(this,"title",ui->comboBox->currentData()); }*/}
#include "qactiontest.h"
#include "ui_qactiontest.h"
QActionTest::QActionTest(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::QActionTest)
{
ui->setupUi(this);
statLabel = new QLabel(this);
statProgressBar = new QProgressBar(this);
ui->statusBar->addPermanentWidget(statLabel);
ui->statusBar->addPermanentWidget(statProgressBar,1);
statLabel->setText("hello");
statProgressBar->setValue(50);
}
QActionTest::~QActionTest()
{
delete ui;
}

本文介绍了一个使用Qt的QDialog派生类实现的简单图表应用示例,其中包括了如何设置下拉组合框并连接其信号到槽函数以显示用户选择的内容。此外,还展示了如何在Qt主窗口中添加状态栏及其常用组件。
23

被折叠的 条评论
为什么被折叠?



