karthikkm1987
5th December 2011, 07:12
Hai I got these two errors while compiling .I dont know what mistakes I have done.
Please help me.
/home/karthik/modbus_multiple_devices/modbus1arm/modbusarm-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/../modbusarm/main.cpp:3: In file included from ../modbusarm/main.cpp:3:
/home/karthik/modbus_multiple_devices/modbus1arm/modbusarm-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/../modbusarm/modbusarm.h:13: error: expected class-name before ‘{’ token
/home/karthik/modbus_multiple_devices/modbus1arm/modbusarm-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/../modbusarm/main.cpp:3: In file included from ../modbusarm/main.cpp:3:
/home/karthik/modbus_multiple_devices/modbus1arm/modbusarm-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/../modbusarm/main.cpp:3: In file included from ../modbusarm/main.cpp:3:
/home/karthik/modbus_multiple_devices/modbus1arm/modbusarm-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/../modbusarm/modbusarm.h:-1: In constructor ‘modbusarm::modbusarm()’:
/home/karthik/modbus_multiple_devices/modbus1arm/modbusarm-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/../modbusarm/modbusarm.h:19: error: ‘setupUi’ was not declared in this scope
Here is the code.
I have put as an attachment.Please help.
please help
karthikkm1987
5th December 2011, 09:18
The code Is
modbusarm.pro
#-------------------------------------------------
#
# Project created by QtCreator 2011-12-05T10:21:56
#
#-------------------------------------------------
QT += core gui
TARGET = modbusarm
TEMPLATE = app
SOURCES += main.cpp
HEADERS += modbusarm.h ui_modbusarm.h
FORMS += modbusarm.ui
The sources are:-
main.cpp:-
#include <QApplication>
#include "modbusarm.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
modbusarm* w=new modbusarm();
w->show();
return a.exec();
}
The headers are:-
modbusarm.h
#ifndef MODBUSARM_H
#define MODBUSARM_H
#include<QDialog>
#include<QtGui>
#include<QProcess>
#include<QMainWindow>
#include"ui_modbusarm.h"
class modbusarm:public QMainWindow,public Ui_modbusarm::MainWindow
{
Q_OBJECT
public:
modbusarm()
{
setupUi(this);
/* create QProcess object */
QProcess* proc1= new QProcess();
QString stringproc1="/home/karthik/modbus_multiple_devices/adcserver1sh";
proc1->start(stringproc1);
/* show output */
connect(proc1, SIGNAL(readyReadStandardOutput()),this, SLOT(arm1->setText()) );
// connect(proc1, SIGNAL(readyReadStandardError()), this, SLOT(wrongMessage1()) );
/*------------------------------------------------------------------------------------------*/
/* create QProcess object */
QProcess* proc2= new QProcess();
QString stringproc2=" /home/karthik/modbus_multiple_devices/adcserver2sh";
proc2->start(stringproc2);
/* show output */
connect(proc2, SIGNAL(readyReadStandardOutput()),this, SLOT(arm2->setText()) );
//connect(proc2, SIGNAL(readyReadStandardError()), this, SLOT(wrongMessage2()) );
}
~modbusarm();
private:
//Ui::modbusarm *ui;
};
#endif // MODBUSARM_H
ui_modbusarm.h:-
/************************************************** ******************************
** Form generated from reading UI file 'modbusarm.ui'
**
** Created: Mon Dec 5 11:28:05 2011
** by: Qt User Interface Compiler version 4.7.4
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
************************************************** ******************************/
#ifndef UI_MODBUSARM_H
#define UI_MODBUSARM_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QMainWindow>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_modbusarm
{
public:
QWidget *centralWidget;
QLineEdit *arm1;
QLineEdit *arm2;
QLabel *label;
QLabel *label_2;
void setupUi(QMainWindow *modbusarm)
{
if (modbusarm->objectName().isEmpty())
modbusarm->setObjectName(QString::fromUtf8("modbusarm"));
modbusarm->resize(400, 300);
centralWidget = new QWidget(modbusarm);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
arm1 = new QLineEdit(centralWidget);
arm1->setObjectName(QString::fromUtf8("arm1"));
arm1->setGeometry(QRect(90, 80, 221, 25));
arm2 = new QLineEdit(centralWidget);
arm2->setObjectName(QString::fromUtf8("arm2"));
arm2->setGeometry(QRect(90, 160, 221, 25));
label = new QLabel(centralWidget);
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(90, 40, 141, 21));
label_2 = new QLabel(centralWidget);
label_2->setObjectName(QString::fromUtf8("label_2"));
label_2->setGeometry(QRect(90, 130, 141, 21));
modbusarm->setCentralWidget(centralWidget);
retranslateUi(modbusarm);
QMetaObject::connectSlotsByName(modbusarm);
} // setupUi
void retranslateUi(QMainWindow *modbusarm)
{
modbusarm->setWindowTitle(QApplication::translate("modbusarm", "modbusarm", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("modbusarm", "Friendly ARM1", 0, QApplication::UnicodeUTF8));
label_2->setText(QApplication::translate("modbusarm", "Friendly ARM2", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class modbusarm: public Ui_modbusarm {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MODBUSARM_H
Spitfire
5th December 2011, 10:45
First - use CODE tags.
Second - your code is a mess.
Third - There's several issues with your code and the error messages tell you everything you need to know.
To make your code compile you need to change line
class modbusarm:public QMainWindow,public Ui_modbusarm::MainWindowto
class modbusarm : public QMainWindow, public Ui_modbusarm
and delete line
~modbusarm();
But I would question why you are inheriting from Ui_modbusarm?
Wouldn't it be simpler to do it correct way:
class modbusarm:public QMainWindow
{
Q_OBJECT
public:
modbusarm()
:
ui( new Ui::modbusarm )
{
ui->setupUi( this );
// more stuff here ...
// more stuff here ...
// more stuff here ...
}
private:
Ui::modbusarm* ui;
};
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.