woeful
دوشنبه 04 بهمن 1389, 11:55 صبح
سلام
کد رو compile میکنم ارور زیر رو میگیرم :
woeful@woeful:~/Desktop/Qt/Qt Book/image$ make
g++ -Wl,-O1 -o image fliptransaction.o main.o mainwindow.o transactionthread.o moc_mainwindow.o moc_transactionthread.o qrc_project.o -L/usr/lib -lQtGui -lQtCore -lpthread
moc_mainwindow.o: In function `MainWindow::qt_metacall(QMetaObject::Call, int, void**)':
moc_mainwindow.cpp:(.text+0xa7): undefined reference to `MainWindow::addTransactionsDone()'
collect2: ld returned 1 exit status
make: *** [image] Error 1
علی رقم این که من تابع ()addTransactionsDone رو در داخل کلاس mainwindow دارم
تابحال کسی بوده کدشو اجرا کنم ارور نگیره :عصبانی++:
کد mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include<QMainWindow>
#include"transactionthread.h"
#include"transaction.h"
class QMenu;
class QAction;
class QLabel;
class QString;
class MainWindow : public QMainWindow
{
Q_OBJECT;
public :
MainWindow();
void setCurrentFile(const QString str)
{currentFile = str;}
private slots :
void flipHorizontally();
void addTransactionsDone();
void allTransactionsDone();
private :
void createActions();
void createMenus();
void addTransaction(Transaction *transact);
QLabel *imageLabel;
QMenu *file;
QMenu *edit;
QMenu *help;
QMenu *convert;
//file
QAction *newAct;
QAction *openAct;
QAction *saveAct;
QAction *saveAsAct;
QAction *exitAct;
//edit
QAction *flipH;
QAction *flipV;
QAction *resize;
//convert
QAction *_1Bit;
QAction *_8Bit;
QAction *_32Bit;
//help
QAction *about;
QAction *qAbout;
QString currentFile;
TransactionThread thread;
};
#endif
کد mianwindow.cpp
#include<QtGui>
#include"mainwindow.h"
#include"fliptransaction.h"
MainWindow::MainWindow()
{
//some code
setCurrentFile("");
}
void MainWindow::addTransaction(Transaction *transact)
{
thread.addTransaction(transact);
openAct->setEnabled(false);
saveAct->setEnabled(false);
saveAsAct->setEnabled(false);
}
void MainWindow::allTransactionsDone()
{
//some code
}
void MainWindow::flipHorizontally()
{
addTransaction(new FlipTransaction(Qt::Horizontal));
}
void MainWindow::createActions()
{
//some code
}
void MainWindow::createMenus()
{
//some code
}
این کد مربوط مشه به کتاب c-gui-programming-with-qt-4-2ndedition
بخش 14. Multithreading
قسمت Communicating with the Main Thread
اگه کسی این کتاب رو خونده و برنامه این قسمت رو نوشته و برنامه درست run شده یه زحمت بکشه کد هاشو برای من upload کنه.
باتشکر
Woeful
کد رو compile میکنم ارور زیر رو میگیرم :
woeful@woeful:~/Desktop/Qt/Qt Book/image$ make
g++ -Wl,-O1 -o image fliptransaction.o main.o mainwindow.o transactionthread.o moc_mainwindow.o moc_transactionthread.o qrc_project.o -L/usr/lib -lQtGui -lQtCore -lpthread
moc_mainwindow.o: In function `MainWindow::qt_metacall(QMetaObject::Call, int, void**)':
moc_mainwindow.cpp:(.text+0xa7): undefined reference to `MainWindow::addTransactionsDone()'
collect2: ld returned 1 exit status
make: *** [image] Error 1
علی رقم این که من تابع ()addTransactionsDone رو در داخل کلاس mainwindow دارم
تابحال کسی بوده کدشو اجرا کنم ارور نگیره :عصبانی++:
کد mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include<QMainWindow>
#include"transactionthread.h"
#include"transaction.h"
class QMenu;
class QAction;
class QLabel;
class QString;
class MainWindow : public QMainWindow
{
Q_OBJECT;
public :
MainWindow();
void setCurrentFile(const QString str)
{currentFile = str;}
private slots :
void flipHorizontally();
void addTransactionsDone();
void allTransactionsDone();
private :
void createActions();
void createMenus();
void addTransaction(Transaction *transact);
QLabel *imageLabel;
QMenu *file;
QMenu *edit;
QMenu *help;
QMenu *convert;
//file
QAction *newAct;
QAction *openAct;
QAction *saveAct;
QAction *saveAsAct;
QAction *exitAct;
//edit
QAction *flipH;
QAction *flipV;
QAction *resize;
//convert
QAction *_1Bit;
QAction *_8Bit;
QAction *_32Bit;
//help
QAction *about;
QAction *qAbout;
QString currentFile;
TransactionThread thread;
};
#endif
کد mianwindow.cpp
#include<QtGui>
#include"mainwindow.h"
#include"fliptransaction.h"
MainWindow::MainWindow()
{
//some code
setCurrentFile("");
}
void MainWindow::addTransaction(Transaction *transact)
{
thread.addTransaction(transact);
openAct->setEnabled(false);
saveAct->setEnabled(false);
saveAsAct->setEnabled(false);
}
void MainWindow::allTransactionsDone()
{
//some code
}
void MainWindow::flipHorizontally()
{
addTransaction(new FlipTransaction(Qt::Horizontal));
}
void MainWindow::createActions()
{
//some code
}
void MainWindow::createMenus()
{
//some code
}
این کد مربوط مشه به کتاب c-gui-programming-with-qt-4-2ndedition
بخش 14. Multithreading
قسمت Communicating with the Main Thread
اگه کسی این کتاب رو خونده و برنامه این قسمت رو نوشته و برنامه درست run شده یه زحمت بکشه کد هاشو برای من upload کنه.
باتشکر
Woeful