Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- widget.cpp
- /////////
- #include "widget.h"
- #include "ui_widget.h"
- #include <iostream>
- #include <cstdlib>
- Widget::Widget(QWidget *parent)
- : QWidget(parent)
- , ui(new Ui::Widget)
- {
- ui->setupUi(this);
- connect(ui->pushButton, SIGNAL(clicked(bool)),this, SLOT(showWords()) );
- }
- Widget::~Widget()
- {
- delete ui;
- }
- void Widget::showWords()
- {
- QString words[] = {"пословица1", "пословица2", "пословица3"};
- ui->label->setText(words[rand()/3]);
- }
- ////////
- main.cpp
- ////////
- #include "widget.h"
- #include <QApplication>
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- Widget w;
- w.show();
- return a.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement