main.cpp
Код: Выделить всё
#include <QApplication>
#include "main_window.h"
int main (int argc, char *argv[]) {
QApplication qa(argc,argv);
main_window mw;
mw.show();
return qa.exec();
};main_window.h
Код: Выделить всё
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include "main_window.h"
#include "ui_main_window.h"
#include <QWidget>
#include <QFileDialog>
#include <QMessageBox>
#include <QTimer>
class main_window: public QWidget {
Q_OBJECT
public:
QString file_name;
QFile f;
int *buf;
int *buffft;
int bs,zzz;
QTimer *timer;
Ui_Form ui;
main_window();
public slots:
void drawArray(int arr[], int s, int max);
void drawArrayS(int arr[], int s, int max);
void open_file ();
void play ();
void stop ();
void timeout();
};
#endifmain_window.cpp
Код:
#include "../src/main_window.h"
main_window::main_window()
:QWidget()
{
ui.setupUi(this);
timer = new QTimer();
buf = NULL;
buffft = NULL;
connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
connect(ui.pushButton,SIGNAL(clicked()),this,SLOT(open_file()));
connect(ui.pushButton_2,SIGNAL(clicked()),this,SLOT(play()));
connect(ui.pushButton_3,SIGNAL(clicked()),this,SLOT(stop()));
}
void main_window::timeout() {
timer->stop();
QFile fd ("/proc/mod_fft");
fd.open(QIODevice::ReadWrite);
QByteArray b = f.read(bs);
if (b.size() < bs) {
fd.close();
return;
}
fd.write(b);
QByteArray bfft = fd.readAll();
memcpy((void*)buf,(void*)b.data(),bs);
memcpy((void*)buffft,(void*)bfft.data(),bs);
drawArray(buffft,bs/4/zzz,2147483647);
drawArrayS(buf,bs/4,2147483647);
fd.close();
timer->start(15);
}
void main_window::play () {
if (file_name == "") {
QMessageBox::information(this,"Error","Select File");
}
zzz = ui.lineEdit->text().toInt();
bs = (1 << zzz)*4;
if (buf) free(buf);
if (buffft) free(buffft);
buf = (int*)malloc(bs);
buffft = (int*)malloc(bs);
f.setFileName(file_name);
f.open(QIODevice::ReadOnly);
timer->start(1);
}
void main_window::stop () {
timer->stop();
f.close();
}
void main_window::open_file () {
file_name = QFileDialog::getOpenFileName(this, trUtf8("Выбор файла"),trUtf8("."));
}
void main_window::drawArray(int arr[],int s,int max) {
int x =0;
delete ui.graphicsView->scene();
QGraphicsScene *qs = new QGraphicsScene();
qs->addLine(QLine(x,110,x,110-110),QPen(QColor::fromRgb(255,255,255)));
for (int i = 0; i < 284; i ++ ) {
x ++;
float xx = s;
xx /= 284;
xx *= i;
int p = xx;
xx = arr[p];
xx /= max;
xx *= 110;
p = abs(xx);
qs->addLine(QLine(x,110,x,110-p),QPen(1));
}
ui.graphicsView->setScene(qs);
};
void main_window::drawArrayS(int arr[],int s,int max) {
int x =0 , lp = 55;
delete ui.graphicsView_2->scene();
QGraphicsScene *qs = new QGraphicsScene();
qs->addLine(QLine(x,100,x,0),QPen(QColor::fromRgb(255,255,255)));
for (int i = 0; i < 248; i ++ ) {
x ++;
float xx = s;
xx /= 248;
xx *= i;
int p = xx;
xx = arr[p];
xx /= max;
xx *= 45;
p = xx;
qs->addLine(QLine(x,lp,x,70-p),QPen(1));
lp = p;
}
ui.graphicsView_2->setScene(qs);
};Делаю Build->Build Project выдаёт:
cd '/home/vania/tolkodubov/tolkodubov/qt4_util' && LC_MESSAGES="C" LC_CTYPE="C" gmake install
gmake: *** No rule to make target `/usr/share/qt4/mkspecs/linux-g++/qmake.conf', needed by `Makefile'. Stop.
*** Exited with status: 2 ***
Makefile KDevelop сам генерит на уровне кода ошибок нет.
Как его правильно откомпилировать?