Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

'QInputDialog' has not been declared - embadded development



  • Hi All,

    Details/Scenario:
    I am developing qtopia widget application that required user selection at a point. The main target is during the user selection I want my application code afterwards should be paused until user selects or cancels the provided option.

    Testing:
    I tried to create widget2 and set is using setCentralWidget() resulting ui is changed but the next remaining code also executed.
    Issue:
    I searched and found that I should use QInputDialogue class to achieve my target. I create the code and include the header file but I am getting error : 'QInputDialog' has not been declared

    If anybody can help me to solve this issue or any alternative to achieve my target scenario.

    Thanks
    Kashif


  • Lifetime Qt Champion

    Hi,

    What version of Qt are you using ?
    On what platform ?


  • Moderators

    Might be obvious but did you actually include it?

    #include <QInputDialog>

    Also, this is something you would need for any GUI, but make sure you have QT += widgets in your qmake.



  • Hi @SGaist,

    The device builtin version is QT4.6/QT Extended 4.4 and I can not update QT version. Device platform is Linux Kernel 2.6.32 and development environment is Debian Linux 7.8.

    Thanks



  • Hi @ambershark,

    I have included using both ways:

    #include <QInputDialog>
    #include <QtGui/QInputDialog>
    

    I am not using qmake but using make file to use cross compiler provided by the device vendor and it does not contains any configurations, whereas my configurations are placed inside project file (qbuild.pro).

    QT += widgets
    

    This configuration is not defined in ".pro" file but all widgets (gui) including text label, input line, command buttons are working fine in my application.

    Thanks


  • Moderators

    @Kashif Ok, can we see the actual build output?

    Also you can check on your embedded device if you actually have the QInputDialog file. Most embedded devices are linux, so you should be able to use the command find /path/to/your/qt -iname "qinputdialog" and see if it actually exists in the Qt installed on your target system.

    The actual build output and possibly the code file where you try to create the object would be helpful.

    Also, if you could answer @SGaist 's questions from above that would help too.

    Oh and sharing the build Makefile may help too, and your qbuild.pro file.



  • Hi @ambershark,

    Following is the result of find command:

     gmx@GMX-SDK:~$ sudo find / -iname "qinputdialog"
    /usr/include/qt4/QtGui/QInputDialog
    /opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtGui/QInputDialog
    /opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/host/include/QtGui/QInputDialog
    gmx@GMX-SDK:~$
    

    I am unable to upload/attach any file anyways, MakeFile Contents:

    CROSS_COMPILE?=$(shell gmx-sdk-cross-compile)
    
    NAME:=$(shell basename `pwd`)
    TARGET:=$(NAME)
    SRCS:=$(wildcard *.c)
    
    $(TARGET): $(SRCS)
            $(CROSS_COMPILE)gcc -o $@ $< -Wall -Werror -lrt
    
    deploy: $(TARGET)
    	scp $(TARGET) root@sk:/usr/bin
    
    test: deploy
    	ssh root@sk $(NAME)
    
    clean:
    	rm -f $(TARGET)
    
    

    quild.pro contents:

    TEMPLATE = app 
    #This is the (name+version) for final product
    #version date : 20171103
    TARGET = QR_EFT_01.07
    CONFIG += qtopia
    #CONFIG += qtopia debug
    
    #LIBS += -lOemDecode -lrpc -lbluetooth -lytprinter -lcurl -lgps -lytlibs
    LIBS += -lrpc
    
    MODULES *= qtopiacomm
    # These are the source files that get built to create the application
    FORMS = 
    # These are the defines to control functionality in application during compilation
    #DEFINES += MAKE_CTLS += MAKE_TOPUP MAKE_SMARTINIT
    DEFINES += MAKE_EMV MAKE_SPDH DBGTRACE
    
    #QT += xml
    
    HEADERS = \
        Sources/Common/Data/struct.h \
        Sources/Common/Txn_flow/transdef.h \
        Sources/Isc_OS/DbgTrace.h \
    	...
    
    SOURCES = \
        gprs_connect.cpp \
        main.cpp \
        Sources/Common/Txn_flow/funct2.cpp \
        Sources/Common/Data/appdata.c \
        Sources/IscSDK/utllib.c \
    	...
    
    OTHER_FILES += \
        Sources/Isc_OS/equates.inc
    
    #include for beeper
    LIBS += -lQtMultimedia
    INCLUDEPATH += /opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/
    
    

    I have already replied to SGaist.

    Thanks


  • Moderators

    @Kashif Can I see the output from the compile? Everything looks in order so maybe the actual error message and output will shed some light on this.

    I have already replied to SGaist.

    You sure did, sorry missed that, lol.



  • Hi @ambershark,

    Following is the output result:

    qbuild
    arm-unknown-linux-gnueabi-g++ /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp
    arm-unknown-linux-gnueabi-g++ -MMD -MF /home/gmx/Documents/gmx-examples/QR_EFT/.obj/gprs_connect.cpp.d -c -pipe -DQT_KEYPAD_NAVIGATION -mabi=aapcs-linux -I/data/home/builder/build/trunk-builder/.toolchain/arm-unknown-linux-gnueabi/sysroot/usr/include -Wall -W -O2 -O2 -DQTOPIA_NO_PAGE_SIZE_MASK -DQT_QWS_CLIENTBLIT -DQTOPIA_NO_PAGE_SIZE_MASK -DQTOPIA_POSIX_LOCKS -DQTOPIA_HAVE_SEMTIMEDOP -DQT_NO_QWS_VFB -DQTOPIA_HAVE_V4L2 -DQTOPIA_TELEPHONY -DMEDIA_SERVER -DQTOPIA_MOBILEUI -DQTOPIA_NO_PAGE_SIZE_MASK -DQT_QWS_CLIENTBLIT -DQTOPIA_NO_PAGE_SIZE_MASK -DQTOPIA_CELL -DQTOPIA_BLUETOOTH -DQT_NO_SXE -DUSE_PICTUREFLOW -DQT_KEYPAD_NAVIGATION -DBUILDER=""\""builder@builder.youtransactor.com\"""" -DMAKE_EMV -DMAKE_SPDH -DDBGTRACE -DQTOPIA_TARGET=""\""QR_EFT_01.07\"""" -DQT_NO_DEBUG -DQT_DBUS_LIB -DQT_SVG_LIB -DQT_SQL_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/mkspecs/qws/linux-yt-g++ -I/home/gmx/Documents/gmx-examples/QR_EFT/qtopiacore/target/mkspecs/qws/linux-yt-g++ -I/home/gmx/Documents/gmx-examples/QR_EFT/data/home/builder/build/trunk-builder/.build/qt-extended-4.4.3/qtopiacore/qt/mkspecs/qws/linux-yt-g++ -I/home/gmx/Documents/gmx-examples/QR_EFT/.uic -I/home/gmx/Documents/gmx-examples/QR_EFT/.moc -I/home/gmx/Documents/gmx-examples/QR_EFT -I/data/home/builder/build/trunk-builder/.build/qt-extended-4.4.3/devices/youtransactor/include -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/ -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiacomm -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiacomm/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/openobex -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/openobex/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiabase -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiabase/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopia -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopia/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/md5 -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/md5/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiagfx -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiagfx/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtDBus -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtSvg -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtSql -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtXml -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtGui -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtNetwork -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtCore -o /home/gmx/Documents/gmx-examples/QR_EFT/.obj/gprs_connect.o /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp
    In file included from /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp:45:0:
    /home/gmx/Documents/gmx-examples/QR_EFT/Sources/Isc_OS/DbgTrace.h:154:0: warning: "DBGTRACE" redefined [enabled by default]
     #define DBGTRACE( level, class, format, ...)    DBGPRINTF(level,class, format, ##__VA_ARGS__)
     ^
    <command-line>:0:0: note: this is the location of the previous definition
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp: In function 'int WriteTermFloorDate()':
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp:2812:1: warning: no return statement in function returning non-void [-Wreturn-type]
     }
     ^
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp: In member function 'int GPRSConnect::UserSelection(unsigned char*, short unsigned int)':
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp:3770:20: error: 'QInputDialog' has not been declared
         QString item = QInputDialog::getItem(this, tr("QInputDialog::getItem()"),
                        ^
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp: In function 'UBYTE UpdFieldsPostAppSel()':
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp:3079:1: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
    *** Error 
    /default: Prerequisite failed
    /target: Prerequisite failed
    /target_post: Prerequisite failed
    /cpp_compiler_target: Prerequisite failed
    /gprs_connect.o: Command execution failed
    $$MKSPEC.CXX -MMD -MF $$[OUTPUT.1] -c $${COMPILER.CXXFLAGS} $${COMPILER.DEFINES} $${COMPILER.INCLUDEPATH} -o $$[OUTPUT.0] $$[INPUT.0]
    arm-unknown-linux-gnueabi-g++ -MMD -MF /home/gmx/Documents/gmx-examples/QR_EFT/.obj/gprs_connect.cpp.d -c -pipe -DQT_KEYPAD_NAVIGATION -mabi=aapcs-linux -I/data/home/builder/build/trunk-builder/.toolchain/arm-unknown-linux-gnueabi/sysroot/usr/include -Wall -W -O2 -O2 -DQTOPIA_NO_PAGE_SIZE_MASK -DQT_QWS_CLIENTBLIT -DQTOPIA_NO_PAGE_SIZE_MASK -DQTOPIA_POSIX_LOCKS -DQTOPIA_HAVE_SEMTIMEDOP -DQT_NO_QWS_VFB -DQTOPIA_HAVE_V4L2 -DQTOPIA_TELEPHONY -DMEDIA_SERVER -DQTOPIA_MOBILEUI -DQTOPIA_NO_PAGE_SIZE_MASK -DQT_QWS_CLIENTBLIT -DQTOPIA_NO_PAGE_SIZE_MASK -DQTOPIA_CELL -DQTOPIA_BLUETOOTH -DQT_NO_SXE -DUSE_PICTUREFLOW -DQT_KEYPAD_NAVIGATION -DBUILDER=""\""builder@builder.youtransactor.com\"""" -DMAKE_EMV -DMAKE_SPDH -DDBGTRACE -DQTOPIA_TARGET=""\""QR_EFT_01.07\"""" -DQT_NO_DEBUG -DQT_DBUS_LIB -DQT_SVG_LIB -DQT_SQL_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/mkspecs/qws/linux-yt-g++ -I/home/gmx/Documents/gmx-examples/QR_EFT/qtopiacore/target/mkspecs/qws/linux-yt-g++ -I/home/gmx/Documents/gmx-examples/QR_EFT/data/home/builder/build/trunk-builder/.build/qt-extended-4.4.3/qtopiacore/qt/mkspecs/qws/linux-yt-g++ -I/home/gmx/Documents/gmx-examples/QR_EFT/.uic -I/home/gmx/Documents/gmx-examples/QR_EFT/.moc -I/home/gmx/Documents/gmx-examples/QR_EFT -I/data/home/builder/build/trunk-builder/.build/qt-extended-4.4.3/devices/youtransactor/include -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/ -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiacomm -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiacomm/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/openobex -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/openobex/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiabase -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiabase/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopia -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopia/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/md5 -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/md5/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiagfx -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/include/qtopiagfx/module -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtDBus -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtSvg -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtSql -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtXml -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtGui -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtNetwork -I/opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtCore -o /home/gmx/Documents/gmx-examples/QR_EFT/.obj/gprs_connect.o /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp
    In file included from /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp:45:0:
    /home/gmx/Documents/gmx-examples/QR_EFT/Sources/Isc_OS/DbgTrace.h:154:0: warning: "DBGTRACE" redefined [enabled by default]
     #define DBGTRACE( level, class, format, ...)    DBGPRINTF(level,class, format, ##__VA_ARGS__)
     ^
    <command-line>:0:0: note: this is the location of the previous definition
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp: In function 'int WriteTermFloorDate()':
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp:2812:1: warning: no return statement in function returning non-void [-Wreturn-type]
     }
     ^
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp: In member function 'int GPRSConnect::UserSelection(unsigned char*, short unsigned int)':
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp:3770:20: error: 'QInputDialog' has not been declared
         QString item = QInputDialog::getItem(this, tr("QInputDialog::getItem()"),
                        ^
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp: In function 'UBYTE UpdFieldsPostAppSel()':
    /home/gmx/Documents/gmx-examples/QR_EFT/gprs_connect.cpp:3079:1: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
    
    make: *** [QR_EFT] Error 1
    

    Thanks


  • Moderators

    @Kashif Hmm this is really weird ...

    Can you check permissions on the QInputDialog files in /opt/ .. those are the ones it should be using to cross compile. Make sure you have read permissions to them.

    Next, let's see if maybe the qmake you are using is finding the wrong qmake or something, run qmake -query and paste results here.

    I'm kind of reaching at this point though. Everything looks good so far like it should work.

    Another idea is create a simple project that just has a main and a QInputDialog::getText or something and see if you can get that to build with your cross compiler toolchain. Take all the complexity from your actual project out of it.



  • Hi @ambershark,

    Following are the permissions:

    gmx@GMX-SDK:~$ ls -l /usr/include/qt4/QtGui/QInputDialog
    -rw-r--r-- 1 root root 26 Apr 26  2012 /usr/include/qt4/QtGui/QInputDialog
    gmx@GMX-SDK:~$ 
    gmx@GMX-SDK:~$ 
    gmx@GMX-SDK:~$ 
    gmx@GMX-SDK:~$ 
    gmx@GMX-SDK:~$ ls -l /opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtGui/QInputDialog
    -rw-r--r-- 1 root root 26 Jun  7  2013 /opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/target/include/QtGui/QInputDialog
    gmx@GMX-SDK:~$ 
    gmx@GMX-SDK:~$ 
    gmx@GMX-SDK:~$ 
    gmx@GMX-SDK:~$ ls -l /opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/host/include/QtGui/QInputDialog
    -rw-r--r-- 1 root root 26 Jun  7  2013 /opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/host/include/QtGui/QInputDialog
    gmx@GMX-SDK:~$ 
    gmx@GMX-SDK:~$ 
    

    qmake -query results:

    gmx@GMX-SDK:~$ qmake -query
    QT_INSTALL_PREFIX:/usr
    QT_INSTALL_DATA:/usr/share/qt4
    QT_INSTALL_DOCS:/usr/share/qt4/doc
    QT_INSTALL_HEADERS:/usr/include/qt4
    QT_INSTALL_LIBS:/usr/lib/x86_64-linux-gnu
    QT_INSTALL_BINS:/usr/bin
    QT_INSTALL_PLUGINS:/usr/lib/x86_64-linux-gnu/qt4/plugins
    QT_INSTALL_IMPORTS:/usr/lib/x86_64-linux-gnu/qt4/imports
    QT_INSTALL_TRANSLATIONS:/usr/share/qt4/translations
    QT_INSTALL_CONFIGURATION:/etc/xdg
    QT_INSTALL_EXAMPLES:/usr/lib/qt4/examples
    QT_INSTALL_DEMOS:/usr/lib/qt4/demos
    QMAKE_MKSPECS:/usr/share/qt4/mkspecs
    QMAKE_VERSION:2.01a
    QT_VERSION:4.8.2
    gmx@GMX-SDK:~$ 
    

    Let me try with simple project as you suggested.

    Thanks



  • Hi @ambershark,
    I altered device vendor's sample gui application, comment all widgets and widget-items. Added the code available in qt documentation to test QInoutDialog:getItem.
    Still same error.

    Thanks



  • Hi @Kashif,

    I got the following reply from my device vendor:

    I checked on our SDK and QInputDialog is disabled from the toolchain by default in the QtExtended from qtopia, you can look at
    http://doc.qt.io/archives/qt-4.8 and look for an alternative. the list of disabled elements by qtopia can be found at
    /opt/toolchain/arm-unknown-linux-gnueabi/sysroot/usr/QtopiaSDK/qtopiacore/qconfig-qpe.h
    in your toolchain
    

    Can you please suggest an approach to achieve my target:

    0> User have Purchase Ticket / Refund Ticket options
    1> User selects purchase ticket
    2> Application lists types of tickets
        a> User Selects ticket or cancel (until completion/user selection step 3 should not execute)
    3> Do purchase process or exit purchase process
    

    Thanks


  • Lifetime Qt Champion

    Hi,

    You can build your own QDialog for that purpose or depending on your application a QWizard might also be an option.


  • Moderators

    @Kashif said in 'QInputDialog' has not been declared - embadded development:

    is disabled from the toolchain by default in the QtExtended from qtopia

    Well that makes a lot more sense. :)

    Like @SGaist said, just write your own QDialog. Make it modal by calling it with myDialog->exec() and test that return code for a QDialog::Accepted in order to proceed or QDialog::Rejected in order to exit the process.



  • Hi @SGaist and @ambershark,

    I am planned to create custom dialog using QDialog class, in parallel I have placed a question to device vendor if I can use QDialog? or if I can use QTCore application. I hope I'll get positive reply for at least one of them.

    Thanks for your time and response.


  • Moderators

    @Kashif If you can't use QDialog, there are other ways to simulate it, getting user input from a qwidget and not allowed it to proceed until your widget is closed.

    And if you can't use qwidgets, well then you don't really have a gui and none of this matters. :)



  • Hi @ambershark,

    PreviouslyI have created secondary widget and called it but my parent widget code was also running this was the reason I moved towards QDialog.
    The good new is I have created a custom sample dialog class and it is working as required. Now I have to make it similar to QInputDialog. Following is the code from my custom dialog class:

    #ifndef APPSELECTIONDIALOG_H
    #define APPSELECTIONDIALOG_H
    
    
    #include <QtGui/QDialog>
    #include <QtGui/QVBoxLayout>
    #include <QtGui/QLineEdit>
    #include <QtGui/QPushButton>
    //#include <QtGui/QLabel>
    
    class appSelectionDialog: public QDialog
    {
        Q_OBJECT
    public:
        explicit appSelectionDialog(QWidget *p = 0): QDialog(p) {
            QVBoxLayout *layout = new QVBoxLayout(this);
            lineEdit = new QLineEdit(this);
            QPushButton *button = new QPushButton("Ok", this);
            layout->addWidget(lineEdit);
            layout->addWidget(button);
            setLayout(layout);
    
            connect(button, SIGNAL(clicked()), SLOT(accept()));
        }
    
        QString getText() const {
            return lineEdit->text();
        }
    private:
        QLineEdit *lineEdit;
    };
    
    #endif // APPSELECTIONDIALOG_H
    

    Calling function:

        appSelectionDialog dialog; // dialog object exists
        (void) dialog.exec();    // dialog is visible
        DBGPRINTF(LOG_INFO, CLASS_EMV,"Text [%s]", dialog.getText().toLocal8Bit().constData() );  //This method prints the text on console in c format
    

    If you have reference to make it similar to QInputDialog please share it :)

    Thanks



  • Hi @ambershark,

    Can you please help me how do I modify the constructor to get the parameters similar to QInputDialog::getItem

    Thanks



  • Hi @ambershark,

    I have created the constructor successfully and it display the item in comboBox.

    Thanks for your help.


  • Moderators

    @Kashif Nice! Glad you got everything working.

    Don't forget to mark the topic as solved. :)


Log in to reply