Results 1 to 4 of 4

Thread: Error regarding QString

  1. #1
    Join Date
    Aug 2007
    Posts
    6
    Qt products
    Qt3
    Platforms
    Unix/X11

    Question Error regarding QString

    Hi,

    I am new in Qt. I have wriiten small program in c++ using vi editor in which I included '/usr/lib/qt-3.1/include/qstring.h' and used 'QString' data type. But while compling I m getting error as:

    In file included from /usr/lib/qt-3.1/include/qshared.h:42,
    from /usr/lib/qt-3.1/include/qgarray.h:42,
    from /usr/lib/qt-3.1/include/qmemarray.h:42,
    from /usr/lib/qt-3.1/include/qcstring.h:43,
    from /usr/lib/qt-3.1/include/qstring.h:42,
    from DCSPacket.h:5,
    from DCSPacket.cpp:1:
    /usr/lib/qt-3.1/include/qglobal.h:710:21: qconfig.h: No such file or directory
    /usr/lib/qt-3.1/include/qglobal.h:773:23: qfeatures.h: No such file or directory




    Please help to solve this error.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Error regarding QString

    Could we see the code? Did you use qmake to compile your application?

  3. #3
    Join Date
    Aug 2007
    Posts
    6
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Error regarding QString

    Thanks for replying !
    I used "g++ DCSPacket.cpp" for compling.

    Here is the code :



    In 'DCSPacket.h ':

    #ifndef DCSPacket_H
    #define DCSPacket_H
    #include<stdlib.h>
    #include<sys/types.h>
    #include </usr/lib/qt-3.1/include/qstring.h>
    #include<fcntl.h>
    #include<unistd.h>
    #include<iostream.h>
    #include<strstream.h>
    #include<sys/dir.h>
    #include<time.h>
    class DCSPacket
    {
    public:
    DCSPacket();
    ~DCSPacket();

    //Member variables. Total 144 bytes
    QString DCSPkt1; // 1 byte
    long DCSPkt2; // 4 bytes
    long DCSPkt3; // 1 byte
    long DCSPkt4; // 4 bytes
    long DCSPkt5; // 3 bytes
    long DCSPkt6; // 3 bytes
    QString DCSPkt7; // 125 bytes
    long DCSPkt8; // 2 bytes
    QString DCSPkt9; // 1 byte

    void GenSmsPkt(int);
    void ExtSmsPkt(QString);
    };
    #endif



    In 'DCSPacket.cpp' :


    #include "DCSPacket.h"

    extern QString packet;

    DCSPacket:CSPacket(){}

    DCSPacket::~DCSPacket(){}

    void DCSPacket::GenSmsPkt(int ptno)
    {
    DCSPkt1="{";
    DCSPkt2=ptno;
    DCSPkt3=1;
    DCSPkt4=1;
    DCSPkt5=144;
    DCSPkt6=1;
    int fd;
    fd=open("/root/sms/"+ptno,O_RDONLY);
    char buff[125];
    read(fd,buff,sizeof(buff));
    DCSPkt7=buff;
    DCSPkt8=12;
    DCSPkt9="}";
    packet.sprintf("%s%d%d%d%d%d%s%d%s","{",DCSPkt2,DC SPkt3,DCSPkt4,DCSPkt5,DCSPkt6,buff,DCSPkt8,"}");
    }

    void DCSPacket::ExtSmsPkt(QString inBuffer)
    {
    DCSPkt1=(inBuffer.mid(1,1));
    DCSPkt2=(inBuffer.mid(2,4)).toInt();
    DCSPkt3=(inBuffer.mid(6,1)).toInt();
    DCSPkt4=(inBuffer.mid(7,4)).toInt();
    DCSPkt5=(inBuffer.mid(11,3)).toInt();
    DCSPkt6=(inBuffer.mid(14,3)).toInt();
    DCSPkt7=(inBuffer.mid(17,125));
    DCSPkt8=(inBuffer.mid(143,2)).toInt();
    DCSPkt9=(inBuffer.mid(145,1));

    //To Make Directory
    int stat;
    stat=mkdir("/root/sms/"+DCSPkt2,0666);
    if(stat!=0)
    cout<<"Directory could not be created";

    //To create timestamp
    long t;
    struct tm *tp;
    time(&t);
    tp=localtime(&t);
    int mon=tp->tm_mon+1;
    int year=tp->tm_year+1900;
    QString timestamp;
    timestamp.sprintf("%d-%d-%d %d:%d:%d",tp->tm_mday,mon,year,tp->tm_hour,tp->tm_min,tp->tm_sec);
    //system("date '+%c %N'");

    //Store data in File
    int fd;
    fd=open("/root/sms/"+timestamp,O_WRONLY|O_CREAT,0666);
    write(fd,DCSPkt7,sizeof(DCSPkt7));

    }



    In 'main.cpp' :

    #include "DCSPacket.h"

    QString packet;

    int main()
    {
    QString buffer ="{1111211441 abcdefghijklmnopqrstuvwxyz abcdefgijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefgijklmnopqrstuvwxyz abcdefghijklmnopq12}";
    DCSPacket *objExPkt=new DCSPacket();
    objExPkt->ExtSmsPkt(buffer);

    DCSPacket *objGenPkt=new DCSPacket();
    objGenPkt->GenSmsPkt(1111);

    cout<<packet;
    return 0;
    }

    Whether I should use qmake to complile ? then please tell how to use it.
    To use qmake, is it required Qt installed?
    Last edited by Namrata; 22nd October 2007 at 08:31.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Error regarding QString

    You need to use qmake. It's installed with Qt. See the docs: http://doc.trolltech.com/3.3/qmake-manual.html

Similar Threads

  1. QString static callback function from CURL
    By tpf80 in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2007, 20:47
  2. Problem in converting QString to QChar array?
    By KaKa in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2007, 00:38
  3. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  4. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:10
  5. [SOLVED] Widget plugin ... how to ?
    By yellowmat in forum Newbie
    Replies: 10
    Last Post: 29th January 2006, 20:41

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.