Results 1 to 10 of 10

Thread: I can't compile program which I have wrote in windows

  1. #1
    Join Date
    Jul 2008
    Posts
    25
    Thanks
    4
    Qt products
    Qt4

    Default I can't compile program which I have wrote in windows

    !!! This program has got polish names Sry

    for example - file 'main.cpp':
    Qt Code:
    1. #include <QtGui>
    2. #include "mojeokno.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication aplikacja(argc, argv);
    7. MojeOkno okno;
    8. okno.show();
    9. return aplikacja.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    file 'mojeokno.h':
    Qt Code:
    1. #include <QtGui>
    2. #include "ui_okno.h"
    3.  
    4. #ifndef _MOJEOKNO_H_
    5. #define _MOJEOKNO_H_
    6.  
    7. class MojeOkno: public QMainWindow
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. MojeOkno();
    13. ~MojeOkno(){};
    14. private:
    15. QString nazwapliku;
    16.  
    17. QTextEdit *poletekstowe;
    18.  
    19. QMenu *menu;
    20. QAction *menuNew;
    21. QAction *menuOpen;
    22. QAction *menuSave;
    23. QAction *menuSaveAs;
    24. QAction *menuQuit;
    25.  
    26. QToolBar *toolBar;
    27.  
    28. private slots:
    29. void New ();
    30. void Open ();
    31. void Save ();
    32. void SaveAs ();
    33. };
    34.  
    35.  
    36. #endif
    To copy to clipboard, switch view to plain text mode 


    file 'ui_okno.h' - this file I created in Qt Designer in windows:
    Qt Code:
    1. /********************************************************************************
    2. ** Form generated from reading ui file 'okno.ui'
    3. **
    4. ** Created: Mon 7. Jul 20:25:54 2008
    5. ** by: Qt User Interface Compiler version 4.4.0
    6. **
    7. ** WARNING! All changes made in this file will be lost when recompiling ui file!
    8. ********************************************************************************/
    9.  
    10. #ifndef UI_OKNO_H
    11. #define UI_OKNO_H
    12.  
    13. #include <QtCore/QVariant>
    14. #include <QtGui/QAction>
    15. #include <QtGui/QApplication>
    16. #include <QtGui/QButtonGroup>
    17. #include <QtGui/QMainWindow>
    18. #include <QtGui/QMenu>
    19. #include <QtGui/QMenuBar>
    20. #include <QtGui/QStatusBar>
    21. #include <QtGui/QTextEdit>
    22. #include <QtGui/QToolBar>
    23. #include <QtGui/QVBoxLayout>
    24. #include <QtGui/QWidget>
    25.  
    26. QT_BEGIN_NAMESPACE
    27.  
    28. class Ui_Okno
    29. {
    30. public:
    31. QAction *actionOtworz;
    32. QAction *actionZapisz;
    33. QAction *actionNowy;
    34. QAction *actionZapiszjako;
    35. QAction *actionWyjscie;
    36. QWidget *centralwidget;
    37. QVBoxLayout *verticalLayout;
    38. QTextEdit *poletekstowe;
    39. QMenuBar *menubar;
    40. QMenu *menuPlik;
    41. QStatusBar *statusbar;
    42. QToolBar *toolBar;
    43.  
    44. void setupUi(QMainWindow *Okno)
    45. {
    46. if (Okno->objectName().isEmpty())
    47. Okno->setObjectName(QString::fromUtf8("Okno"));
    48. Okno->resize(600, 400);
    49. actionOtworz = new QAction(Okno);
    50. actionOtworz->setObjectName(QString::fromUtf8("actionOtworz"));
    51. QIcon icon;
    52. icon.addPixmap(QPixmap(QString::fromUtf8(":/images/open.png")), QIcon::Normal, QIcon::Off);
    53. actionOtworz->setIcon(icon);
    54. actionZapisz = new QAction(Okno);
    55. actionZapisz->setObjectName(QString::fromUtf8("actionZapisz"));
    56. QIcon icon1;
    57. icon1.addPixmap(QPixmap(QString::fromUtf8(":/images/save.png")), QIcon::Normal, QIcon::Off);
    58. actionZapisz->setIcon(icon1);
    59. actionNowy = new QAction(Okno);
    60. actionNowy->setObjectName(QString::fromUtf8("actionNowy"));
    61. QIcon icon2;
    62. icon2.addPixmap(QPixmap(QString::fromUtf8(":/images/new.png")), QIcon::Normal, QIcon::Off);
    63. actionNowy->setIcon(icon2);
    64. actionZapiszjako = new QAction(Okno);
    65. actionZapiszjako->setObjectName(QString::fromUtf8("actionZapiszjako"));
    66. actionWyjscie = new QAction(Okno);
    67. actionWyjscie->setObjectName(QString::fromUtf8("actionWyjscie"));
    68. centralwidget = new QWidget(Okno);
    69. centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    70. centralwidget->setGeometry(QRect(0, 55, 600, 326));
    71. verticalLayout = new QVBoxLayout(centralwidget);
    72. verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
    73. poletekstowe = new QTextEdit(centralwidget);
    74. poletekstowe->setObjectName(QString::fromUtf8("poletekstowe"));
    75.  
    76. verticalLayout->addWidget(poletekstowe);
    77.  
    78. Okno->setCentralWidget(centralwidget);
    79. menubar = new QMenuBar(Okno);
    80. menubar->setObjectName(QString::fromUtf8("menubar"));
    81. menubar->setGeometry(QRect(0, 0, 600, 21));
    82. menuPlik = new QMenu(menubar);
    83. menuPlik->setObjectName(QString::fromUtf8("menuPlik"));
    84. Okno->setMenuBar(menubar);
    85. statusbar = new QStatusBar(Okno);
    86. statusbar->setObjectName(QString::fromUtf8("statusbar"));
    87. statusbar->setGeometry(QRect(0, 381, 600, 19));
    88. Okno->setStatusBar(statusbar);
    89. toolBar = new QToolBar(Okno);
    90. toolBar->setObjectName(QString::fromUtf8("toolBar"));
    91. toolBar->setGeometry(QRect(0, 21, 600, 34));
    92. Okno->addToolBar(Qt::TopToolBarArea, toolBar);
    93.  
    94. menubar->addAction(menuPlik->menuAction());
    95. menuPlik->addAction(actionOtworz);
    96. menuPlik->addAction(actionZapisz);
    97. menuPlik->addAction(actionNowy);
    98. menuPlik->addAction(actionZapiszjako);
    99. menuPlik->addSeparator();
    100. menuPlik->addAction(actionWyjscie);
    101. toolBar->addAction(actionOtworz);
    102. toolBar->addAction(actionZapisz);
    103. toolBar->addAction(actionNowy);
    104.  
    105. retranslateUi(Okno);
    106.  
    107. QMetaObject::connectSlotsByName(Okno);
    108. } // setupUi
    109.  
    110. void retranslateUi(QMainWindow *Okno)
    111. {
    112. Okno->setWindowTitle(QApplication::translate("Okno", "MainWindow", 0, QApplication::UnicodeUTF8));
    113. actionOtworz->setText(QApplication::translate("Okno", "Otw\303\263rz", 0, QApplication::UnicodeUTF8));
    114. actionZapisz->setText(QApplication::translate("Okno", "Zapisz", 0, QApplication::UnicodeUTF8));
    115. actionNowy->setText(QApplication::translate("Okno", "Nowy", 0, QApplication::UnicodeUTF8));
    116. actionZapiszjako->setText(QApplication::translate("Okno", "Zapisz jako", 0, QApplication::UnicodeUTF8));
    117. actionWyjscie->setText(QApplication::translate("Okno", "Wyj\305\233cie", 0, QApplication::UnicodeUTF8));
    118. menuPlik->setTitle(QApplication::translate("Okno", "Plik", 0, QApplication::UnicodeUTF8));
    119. toolBar->setWindowTitle(QApplication::translate("Okno", "toolBar", 0, QApplication::UnicodeUTF8));
    120. } // retranslateUi
    121.  
    122. };
    123.  
    124. namespace Ui {
    125. class Okno: public Ui_Okno {};
    126. } // namespace Ui
    127.  
    128. QT_END_NAMESPACE
    129.  
    130. #endif // UI_OKNO_H
    To copy to clipboard, switch view to plain text mode 

    I have also other files but these 3. files are the most important because I have mistakes:
    Qt Code:
    1. ui_okno.h:28: error: expected constructor, destructor, or type conversion before ‘class’
    2. ui_okno.h:125: error: expected class-name before ‘{’ token
    3. mojeokno.h:7: error: expected constructor, destructor, or type conversion before ‘class’
    4. main.cpp: In function ‘int main(int, char**)’:
    5. main.cpp:7: error: ‘MojeOkno’ was not declared in this scope
    6. main.cpp:7: error: expected `;' before ‘okno’
    7. main.cpp:8: error: ‘okno’ was not declared in this scope
    8. make: *** [main.o] Błąd 1
    To copy to clipboard, switch view to plain text mode 


    Why? In windows everything was ok.
    Last edited by newplayer; 7th July 2008 at 20:24. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I can't compile program which I have wrote in windows

    Do you use qmake?

  3. #3
    Join Date
    Jul 2008
    Posts
    25
    Thanks
    4
    Qt products
    Qt4

    Default Re: I can't compile program which I have wrote in windows

    yes :

    [jogurtcytrynowy@localhost katalog]$ /usr/lib/qt4/bin/qmake -project
    [jogurtcytrynowy@localhost katalog]$ /usr/lib/qt4/bin/qmake
    [jogurtcytrynowy@localhost katalog]$ make
    g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib/qt4/mkspecs/linux-g++ -I. -I/usr/lib/qt4/include/QtCore -I/usr/lib/qt4/include/QtCore -I/usr/lib/qt4/include/QtGui -I/usr/lib/qt4/include/QtGui -I/usr/lib/qt4/include -I. -I. -I. -o main.o main.cpp
    ui_okno.h:28: error: expected constructor, destructor, or type conversion before ‘class’
    ui_okno.h:125: error: expected class-name before ‘{’ token
    mojeokno.h:7: error: expected constructor, destructor, or type conversion before ‘class’
    main.cpp: In function ‘int main(int, char**)’:
    main.cpp:7: error: ‘MojeOkno’ was not declared in this scope
    main.cpp:7: error: expected `;' before ‘okno’
    main.cpp:8: error: ‘okno’ was not declared in this scope
    make: *** [main.o] Błąd 1
    Last edited by jacek; 8th July 2008 at 12:28. Reason: changed [code] to [quote]

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I can't compile program which I have wrote in windows

    What does "/usr/lib/qt4/bin/qmake -version" output?

    Remove QT_BEGIN_NAMESPACE and QT_END_NAMESPACE from ui_okno.h and it should compile.

  5. #5
    Join Date
    Jul 2008
    Posts
    25
    Thanks
    4
    Qt products
    Qt4

    Default Re: I can't compile program which I have wrote in windows

    thx you very much - now it works !!!!!!!!! XD

  6. #6
    Join Date
    Jul 2008
    Posts
    25
    Thanks
    4
    Qt products
    Qt4

    Default Re: I can't compile program which I have wrote in windows

    Do you know why it works in linux without QT_BEGIN_NAMESPACE and QT_END_NAMESPACE ? Is it a mistake in Qt Designer in windows ?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I can't compile program which I have wrote in windows

    Quote Originally Posted by newplayer View Post
    Do you know why it works in linux without QT_BEGIN_NAMESPACE and QT_END_NAMESPACE ?
    You might be using earlier Qt version. To be sure, answer the question from my previous post.

  8. #8
    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: I can't compile program which I have wrote in windows

    Quote Originally Posted by newplayer View Post
    Do you know why it works in linux without QT_BEGIN_NAMESPACE and QT_END_NAMESPACE ? Is it a mistake in Qt Designer in windows ?
    No, the reason is that you ran "qmake -project" when there were generated intermediate files. Only .ui files should be listed in .pro instead of generated ui_*.h (or any other generated files for that matter). You should run "qmake -project" only once in the beginning of the project, not always when you compile.
    J-P Nurmi

  9. #9
    Join Date
    Jul 2008
    Posts
    25
    Thanks
    4
    Qt products
    Qt4

    Default Re: I can't compile program which I have wrote in windows

    I compiled 'ui_window.h' which I created in windows. Now I am compiling 'window.ui' and everything is ok - thx you both very much.
    I clicked 'thanks button' but I think it doesn't work. :/

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I can't compile program which I have wrote in windows

    Quote Originally Posted by newplayer View Post
    I clicked 'thanks button' but I think it doesn't work. :/
    I've noticed it. It will be fixed by the end of the month. There's no summer for me yet

Similar Threads

  1. qtgui4.dll error in visual c++ 2005
    By Comptrol in forum Installation and Deployment
    Replies: 33
    Last Post: 19th June 2008, 07:18
  2. Replies: 19
    Last Post: 21st January 2008, 09:13
  3. Use VC2005 to compile Qt program (4.3.0)
    By firegun9 in forum Qt Programming
    Replies: 3
    Last Post: 8th June 2007, 16:04
  4. Porting my program to another windows machine !
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 14th March 2007, 06:46
  5. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19

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.