Results 1 to 3 of 3

Thread: please help: "setupUi: identifier not found"

  1. #1
    Join Date
    Jun 2008
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default please help: "setupUi: identifier not found"

    My problem is how to implement setupUi. It gives me "setupUi: identifier not found" error.
    I do not know what do ı need to do now ??
    please help !!

    ı have 3 more classes but they have no relation with setupUi.



    Qt Code:
    1. #ifndef UI_MYTREEWIDGET_H
    2. #define UI_MYTREEWIDGET_H
    3.  
    4. #include <QtCore/QVariant>
    5. #include <QtGui/QAction>
    6. #include <QtGui/QApplication>
    7. #include <QtGui/QButtonGroup>
    8. #include <QtGui/QMainWindow>
    9. #include <QtGui/QMenuBar>
    10. #include <QtGui/QStatusBar>
    11. #include <QtGui/QToolBar>
    12. #include <QtGui/QWidget>
    13. #include <QtGui>
    14.  
    15. class Ui_mytreewidgetClass
    16. {
    17. public:
    18. QMenuBar *menuBar;
    19. QToolBar *mainToolBar;
    20. QWidget *centralWidget;
    21. QStatusBar *statusBar;
    22.  
    23.  
    24.  
    25. void Ui_mytreewidgetClass::setupUi(QMainWindow *mytreewidgetClass)
    26. {
    27.  
    28. if (mytreewidgetClass->objectName().isEmpty())
    29. mytreewidgetClass->setObjectName(QString::fromUtf8("mytreewidgetClass"));
    30. mytreewidgetClass->resize(600, 400);
    31.  
    32. menuBar = new QMenuBar(mytreewidgetClass);
    33. menuBar->setObjectName(QString::fromUtf8("menuBar"));
    34. mytreewidgetClass->setMenuBar(menuBar);
    35.  
    36. mainToolBar = new QToolBar(mytreewidgetClass);
    37. mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
    38. mytreewidgetClass->addToolBar(mainToolBar);
    39.  
    40. centralWidget = new QWidget(mytreewidgetClass);
    41. centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
    42. mytreewidgetClass->setCentralWidget(centralWidget);
    43.  
    44. statusBar = new QStatusBar(mytreewidgetClass);
    45. statusBar->setObjectName(QString::fromUtf8("statusBar"));
    46. mytreewidgetClass->setStatusBar(statusBar);
    47.  
    48. retranslateUi(mytreewidgetClass);
    49.  
    50. QMetaObject::connectSlotsByName(mytreewidgetClass);
    51. } // setupUi
    52.  
    53.  
    54. void retranslateUi(QMainWindow *mytreewidgetClass)
    55. {
    56. mytreewidgetClass->setWindowTitle(QApplication::translate("mytreewidgetClass", "mytreewidget", 0, QApplication::UnicodeUTF8));
    57. Q_UNUSED(mytreewidgetClass);
    58. } // retranslateUi
    59.  
    60.  
    61. };
    62.  
    63. namespace Ui {
    64. class mytreewidgetClass: public Ui_mytreewidgetClass {};
    65. } // namespace Ui
    66.  
    67. #endif // UI_MYTREEWIDGET_H
    To copy to clipboard, switch view to plain text mode 











    Qt Code:
    1. #include <QtGui>
    2. #include "myqtapp.h"
    3.  
    4.  
    5.  
    6. //void setUi(QWidget *mytreewidgetClass);
    7.  
    8.  
    9.  
    10.  
    11.  
    12. myQtApp::myQtApp(QWidget *parent)
    13. {
    14. setupUi( this ); // sets up GUI
    15. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 7th July 2008 at 09:29. Reason: missing [code] tags

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy Re: please help: "setupUi: identifier not found"

    I don't quite follow your code.

    Basically, the idea is as follows:

    Your widgets sets up itself, i.e.

    Qt Code:
    1. // der
    2. class YourWidget : public QWidget, private Ui_YourWidget
    3. {
    4. YourWidget(QWidget *parent=0) : QWidget(parent)
    5. {
    6. setupUi(this);
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 
    or

    Qt Code:
    1. // variant 2: do not derive, place ui as a member variable
    2. class YourWidget :
    3. {
    4. Ui_YourWidget ui;
    5. YourWidget(QWidget *parent=0) : QWidget(parent) {}
    6. {
    7. ui.setupUi(this);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 


    You do not call setupUi from a QApplication(-subclass). Which it looks like you are trying to.

    Your main is then something like:
    Qt Code:
    1. int main(int argc, char **argv)
    2. {
    3. QApplication app(argc,argv); // use your subclass here, if you have one
    4. YourWidget yw;
    5. yw.show();
    6. return app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 

    Of course, more advanced programs will do more. This are but the basic building blocks.

    HTH

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: please help: "setupUi: identifier not found"

    Use either single inheritance or multiple inheritance approach.
    J-P Nurmi

Similar Threads

  1. lib("dnsapi")
    By CHeader in forum Newbie
    Replies: 10
    Last Post: 16th February 2008, 19:21

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.