Results 1 to 9 of 9

Thread: QString in Visual Studio 2005 has compile error

  1. #1
    Join Date
    Mar 2007
    Posts
    30
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation QString in Visual Studio 2005 has compile error

    I was trying to extract the text from the LineEdit generated in QT designer embedded in Visual Studio 2005.
    So it returns QString, so I had to manipulate the QString.

    However, this gives a compile error:

    ClientProject error LNK2019: unresolved external symbol...

    From MSDN I noticed that it is due to the incompatibility of CString derived class with VS,
    Detail see the following web page:

    http://support.microsoft.com/kb/309801

    The page has included a resolution for ATL. But what is the resolution for QT???

    I am in urgent need of a resolution!!!

    Thanks a lot!!!

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QString in Visual Studio 2005 has compile error

    Although the problem may indeed be an exotic one like you claim (i.e some problem with CString), I would first tend to think you are not liking correctly.
    It would be helpful to see your code.
    Can you compile successfully other Qt code with VS2005?

  3. The following user says thank you to high_flyer for this useful post:

    KaKa (13th March 2007)

  4. #3
    Join Date
    Mar 2007
    Posts
    30
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Lightbulb Re: QString in Visual Studio 2005 has compile error

    Thanks very much for replying!

    I can compile well with other code.
    And this problem only occurs when I uncommented the two lines:

    *a=ui.lineEdit_2->text();
    *b=ui.LineEdit-3>text();
    where a and b are declared as QString*, and have been inistialized using QString() before.

    Are these things above useful?

    Thanks a lot!

  5. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QString in Visual Studio 2005 has compile error

    Hmm... hard to tell - can you show a bit more code, the whole function that contains the above code for example?
    I see you are using ui, I guess its a designed class implementation, did you do setupUi()?

  6. #5
    Join Date
    Mar 2007
    Posts
    30
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Red face Re: QString in Visual Studio 2005 has compile error

    Thanks very much again for replying my post, here is some more detailed description of my code:

    1. many of the code was generated automatically after I drew widgets using the VS embedded QT designer, ui is one of them, and the function you mentioned is there and it is automatically generated.

    2. Before showing your the code I hope to say: so basically the logic of this portion of code is:
    I have a QEditLine widget, which has the .text() function to retrieveQString, and I was using declared QStrings to get the .text and send it over to another logic part (declared as a QObject class(the aLogic class below)) to parse those strings(will need to convert the QStrings to char array) but it didn't even go throught the part of the QObject class that checks if the QString passed in are Null.

    So below is the code:

    I. Class set a:

    a.h:

    class a : public QDialog
    {
    Q_OBJECT

    QString *param1;
    QString *param2;


    public:
    a(QWidget *parent = 0);
    ~a();


    private:
    Ui::aClass ui;

    private slots:
    void on_OK3_clicked();
    void on_Reset3_clicked();
    };

    a.cpp:

    a::a(QWidget *parent)
    : QDialog(parent)
    {
    ui.setupUi(this);
    }

    a::~a()
    {

    }


    void a:n_Reset3_clicked()
    {
    ui.lineEdit_2->clear();
    ui.RestLineEdit->clear();
    }

    void a:n_OK3_clicked()
    {
    param1=new QString();
    param2=new QString();
    *param1=ui.lineEdit_2->text();
    *param2=ui.RestLineEdit->text();
    aLogic *theapp=new aLogic();
    int success=theapp->checkaLogic(*param1);
    }

    II. Class set aLogic:

    aLogic.h:

    class aLogic : public QObject
    {
    Q_OBJECT

    QObject *Logicparent;

    public:
    aLogic();
    aLogic(QObject *parent);
    ~aLogic();
    int checkaLogic(QString b);

    private:
    };

    aLogic.cpp:

    aLogic::aLogic(QObject *parent)
    : QObject(parent)
    {
    Logicparent=parent;
    }

    aLogic::~aLogic()
    {

    }


    int aLogic::checkaLogic(QString b)
    {
    if(b.isNull())
    {
    QMessageBox *warmessage=new QMessageBox();
    warmessage->setText("Please enter a string");
    warmessage->setIcon(QMessageBox::Critical);
    return 0;
    }

    return 0;
    }

    Note that in the aLogic class set I wanted to declare param1 and param2 to be type of QString, but because the compiler was complaining that the constructor QString() should return a pointer, so I made param1 and param2 pointers.

    Sorry this is so long...but I am just in such a hurry.

    Thanks very much!

  7. #6
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QString in Visual Studio 2005 has compile error

    Did you connect clicked() signal to your slots???? If not first do that. I dont have Qt4 installed on my system and it is just a guess by seeing your post by reading this statement
    but it didn't even go throught the part of the QObject class that checks if the QString passed in are Null.

  8. The following user says thank you to vermarajeev for this useful post:

    KaKa (14th March 2007)

  9. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QString in Visual Studio 2005 has compile error

    1. many of the code was generated automatically after I drew widgets using the VS embedded QT designer, ui is one of them, and the function you mentioned is there and it is automatically generated.
    What do you mean by that? - did you change any of the designer genrated code?
    Are you sure you are mocing all your QObject classes?
    Did you include the ui_<class>.h generated by designer?

    Oh, and please - use the code quotes for code, it really is hard to read it like that - thanks.
    Last edited by high_flyer; 14th March 2007 at 10:02.

  10. The following user says thank you to high_flyer for this useful post:

    KaKa (14th March 2007)

  11. #8
    Join Date
    Mar 2007
    Posts
    30
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Red face Re: QString in Visual Studio 2005 has compile error

    I finally found the problem.

    I forgot to define the default constructor.

    Thanks for paying all the attention.

    And sorry for bothering high_flyer so much. I really feel guilty now .

  12. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QString in Visual Studio 2005 has compile error

    It is no bother - and don't feel guilty!
    You can PM me any time - but use the PM for things that do NOT concern the forum.
    Posts and Qt questions are very much of iterest to the forum, so their place is here and not in a PM, this way every one can benfit from them!

Similar Threads

  1. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 18:59
  2. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 14:15
  3. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 25th August 2006, 00:31
  4. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 13:52
  5. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 13:54

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.