Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 7

Qt-interest Archive, May 2008
problem with QInputDialog method


Message 1 in thread

Hi All,

  I am using Qtopia 4.3 and am unable to use QInputDialog methods. With some research I undefined QT_NO_INPUTDIALOG in my code. Please find the code piece here under,

/* myexample.h*/
..... 
#ifdef QT_NO_INPUTDIALOG
#undef QT_NO_INPUTDIALOG
#undef QT_NO_DIALOGS
#include <QInputDialog>
#endif
....

/*myexample.cpp*/
......
QString text = QInputDialog::getText(this, tr("QInputDialog::getText()"),
                                          tr("User name:"), QLineEdit::Normal,
                                          QDir::home().dirName(), &ok);
.........



and I am a getting linking error.

myexample.cpp:(.text+0x434): undefined reference to `QInputDialog::getText(QWidget*, QString const&, QString const&, QLineEdit::EchoMode, QString const&, bool*, QFlags<Qt::WindowType>)'
..obj/release-shared/Alerts.o: In function `AlertScreen::AlertScreen(QString, QString, bool)':
myexample.cpp:(.text+0x824): undefined reference to `QInputDialog::getText(QWidget*, QString const&, QString const&, QLineEdit::EchoMode, QString const&, bool*, QFlags<Qt::WindowType>)'
collect2: ld returned 1 exit status

Can anyone help me how to fix this? 

--
 [ signature omitted ] 
Message 2 in thread

Freelancer Kiran wrote:
> Hi All,
>
>   I am using Qtopia 4.3 and am unable to use QInputDialog methods. 
> With some research I undefined QT_NO_INPUTDIALOG in my code. Please 
> find the code piece here under,
>
> /* myexample.h*/
> ....
> #ifdef QT_NO_INPUTDIALOG
> #undef QT_NO_INPUTDIALOG
> #undef QT_NO_DIALOGS
> #include <QInputDialog>
> #endif
> ...
>
> /*myexample.cpp*/
> .....
> QString text = QInputDialog::getText(this, tr("QInputDialog::getText()"),
>                                           tr("User name:"), 
> QLineEdit::Normal,
>                                           QDir::home().dirName(), &ok);
> ........
>
>
>
> and I am a getting linking error.
>
> myexample.cpp:(.text+0x434): undefined reference to 
> `QInputDialog::getText(QWidget*, QString const&, QString const&, 
> QLineEdit::EchoMode, QString const&, bool*, QFlags<Qt::WindowType>)'
> .obj/release-shared/Alerts.o: In function 
> `AlertScreen::AlertScreen(QString, QString, bool)':
> myexample.cpp:(.text+0x824): undefined reference to 
> `QInputDialog::getText(QWidget*, QString const&, QString const&, 
> QLineEdit::EchoMode, QString const&, bool*, QFlags<Qt::WindowType>)'
> collect2: ld returned 1 exit status
>

This not not how those #defines work. If you want to use the input 
dialog code you need to compile both Qt and your app with those 
#defines. In fact once you compile Qt correctly those defines will be 
defined automatically for you. Please read the following on how to 
configure Qtopia:

    http://doc.trolltech.com/4.4/qt-embedded-features.html

Also take note that by default Qtopia comes with all the classes 
enabled. Someone has already modified your Qtopia build. You might want 
look into why it was modified in the 1st place.

--Justin

begin:vcard
begin:vcard
fn:Justin Noel
n:Noel;Justin
org:ICS;Engineering
adr:;;54B Middlesex Trpk.;Bedford;MA;01730;USA
email;internet:justin@xxxxxxx
title:Sr. Consulting Engineer / Certified Qt Instructor
tel;work:617-621-0060
x-mozilla-html:FALSE
url:www.ics.com
version:2.1
end:vcard