Results 1 to 3 of 3

Thread: Errors Occured While compiling.Unable to solve it.

  1. #1
    Join Date
    Dec 2011
    Posts
    13
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Errors Occured While compiling.Unable to solve it.

    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
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2011
    Posts
    13
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Errors Occured While compiling.Unable to solve it.

    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 modbusarmublic 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

  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Errors Occured While compiling.Unable to solve it.

    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
    Qt Code:
    1. class modbusarm:public QMainWindow,public Ui_modbusarm::MainWindow
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. class modbusarm : public QMainWindow, public Ui_modbusarm
    To copy to clipboard, switch view to plain text mode 
    and delete line
    Qt Code:
    1. ~modbusarm();
    To copy to clipboard, switch view to plain text mode 

    But I would question why you are inheriting from Ui_modbusarm?
    Wouldn't it be simpler to do it correct way:
    Qt Code:
    1. class modbusarm:public QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. modbusarm()
    7. :
    8. ui( new Ui::modbusarm )
    9. {
    10. ui->setupUi( this );
    11.  
    12. // more stuff here ...
    13. // more stuff here ...
    14. // more stuff here ...
    15. }
    16.  
    17. private:
    18. Ui::modbusarm* ui;
    19. };
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 26th October 2011, 18:31
  2. Multiple types and other errors compiling qwt app
    By DrunkenUFOPilot in forum Qwt
    Replies: 1
    Last Post: 10th January 2011, 17:54
  3. Replies: 1
    Last Post: 25th December 2010, 07:38
  4. Errors after compiling for Win
    By cejohnsonsr in forum Newbie
    Replies: 3
    Last Post: 26th August 2010, 22:31
  5. compiling errors when using opengl and debug
    By invictus in forum Newbie
    Replies: 3
    Last Post: 31st March 2008, 06:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.