PDA

View Full Version : cant make program run C++ gui programming



Petr_Kropotkin
14th January 2010, 23:17
I get tons of erros for ant make program run C++ gui programming on page 31. I entered the whole program perfectly .
Here it is


finddialog.h
001 #ifndef FINDDIALOG_H
002 #define FINDDIALOG_H
003 #include <QDialog>
004 class QCheckBox;
005 class QLabel;
006 class QLineEdit;
007 class QPushButton;
008 class FindDialog : public QDialog
009 {
010 Q_OBJECT
011 public:
012 FindDialog(QWidget *parent = 0);
013 signals:
014 void findNext(const QString &str, Qt::CaseSensitivity cs);
015 void findPrevious(const QString &str, Qt::CaseSensitivity cs);
016 private slots:
017 void findClicked();
018 void enableFindButton(const QString &text);
019 private:
020 QLabel *label;
021 QLineEdit *lineEdit;
022 QCheckBox *caseCheckBox;
023 QCheckBox *backwardCheckBox;
024 QPushButton *findButton;
025 QPushButton *closeButton;
026 };
027 #endif

finddialog.cpp
001 #include <QtGui>
002 #include "finddialog.h"
003 FindDialog::FindDialog(QWidget *parent)
004 : QDialog(parent)
005 {
006 label = new QLabel(tr("Find &what:"));
007 lineEdit = new QLineEdit;
008 label->setBuddy(lineEdit);
009 caseCheckBox = new QCheckBox(tr("Match &case"));
010 backwardCheckBox = new QCheckBox(tr("Search &backward"));
011 findButton = new QPushButton(tr("&Find"));
012 findButton->setDefault(true);
013 findButton->setEnabled(false);
014 closeButton = new QPushButton(tr("Close"));
015 connect(lineEdit, SIGNAL(textChanged(const QString &)),
016 this, SLOT(enableFindButton(const QString &)));
017 connect(findButton, SIGNAL(clicked()),
018 this, SLOT(findClicked()));
019 connect(closeButton, SIGNAL(clicked()),
020 this, SLOT(close()));
021 QHBoxLayout *topLeftLayout = new QHBoxLayout;
022 topLeftLayout->addWidget(label);
023 topLeftLayout->addWidget(lineEdit);
024 QVBoxLayout *leftLayout = new QVBoxLayout;
025 leftLayout->addLayout(topLeftLayout);
026 leftLayout->addWidget(caseCheckBox);
027 leftLayout->addWidget(backwardCheckBox);
028 QVBoxLayout *rightLayout = new QVBoxLayout;
029 rightLayout->addWidget(findButton);
030 rightLayout->addWidget(closeButton);
031 rightLayout->addStretch();
032 QHBoxLayout *mainLayout = new QHBoxLayout;
033 mainLayout->addLayout(leftLayout);
034 mainLayout->addLayout(rightLayout);
035 setLayout(mainLayout);
036 setWindowTitle(tr("Find"));
037 setFixedHeight(sizeHint().height());
038 }

039 void FindDialog::findClicked()
040 {
041 QString text = lineEdit->text();
042 Qt::CaseSensitivity cs =
043 caseCheckBox->isChecked() ? Qt::CaseSensitive
044 : Qt::CaseInsensitive;
045 if (backwardCheckBox->isChecked()) {
046 emit findPrevious(text, cs);
047 } else {
048 emit findNext(text, cs);
049 }
050 }
051 void FindDialog::enableFindButton(const QString &text)
052 {
053 findButton->setEnabled(!text.isEmpty());
054 }

main.cpp
001 #include <QApplication>
002 #include "finddialog.h"
003 int main(int argc, char *argv[])
004 {
005 QApplication app(argc, argv);
006 FindDialog *dialog = new FindDialog;
007 dialog->show();
008 return app.exec();
009 }




One of the errors Isee is the build choking on #include <QtGui> I finf this happening in some of the demo programs too.
I don't know how to fix this problem HELP !:confused:

gbmtoday
14th January 2010, 23:48
so what are the errors ?

for better undrstanding please put your code between

Petr_Kropotkin
15th January 2010, 00:22
Here is the list
----------------------------------------------------------------------------------------------------
In file included from FindDialog.cpp:2:
c:\Qt\2009.05\qt\include\QtGui/QtGui:7:31: error: qaccessibleobject.h: No such file or directory
In file included from c:\Qt\2009.05\qt\include\QtGui/qaccessiblewidget.h:1,
from c:\Qt\2009.05\qt\include\QtGui/QtGui:9,
from FindDialog.cpp:2:
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:45:37: error: QtGui/qaccessibleobject.h: No such file or directory
In file included from FindDialog.cpp:3:
finddialog.h:49:2: error: #endif without #if
In file included from c:\Qt\2009.05\qt\include\QtGui/qaccessiblewidget.h:1,
from c:\Qt\2009.05\qt\include\QtGui/QtGui:9,
from FindDialog.cpp:2:
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:58: error: expected class-name before '{' token
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:60: error: 'Role' has not been declared
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:64: error: 'Relation' does not name a type
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:68: error: 'RelationFlag' has not been declared
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:70: error: 'Text' has not been declared
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:71: error: 'Role' does not name a type
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:72: error: 'State' does not name a type
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:76: error: 'Text' has not been declared
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:60: error: 'Client' was not declared in this scope
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:98: error: expected class-name before '{' token
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:100: error: 'Role' has not been declared
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:104: error: 'Relation' does not name a type
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:108: error: 'RelationFlag' has not been declared
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:110: error: 'Text' has not been declared
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:111: error: 'Role' does not name a type
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:112: error: 'State' does not name a type
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:114: error: 'Text' has not been declared
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:117: error: 'Method' has not been declared
c:\Qt\2009.05\qt\include\QtGui/../../src/gui/accessible/qaccessiblewidget.h:100: error: 'Client' was not declared in this scope

JD2000
15th January 2010, 12:50
It looks like you have not got QT installed properly, the very first line of the error message indicates that
C:\Qt\2009.03\qt\include\QtGui\qaccessibleobject.h can not be found.

Check to see if this file actually exists on your PC. If it does, there is probably an error in your QT path.

Petr_Kropotkin
15th January 2010, 13:05
ok I am going to reinstall. This is strange, since I have created the hello dialog button and simple popup.

squidge
15th January 2010, 13:10
Ensure your book/tutorial/examples/etc uses Qt4.5, not Qt3. otherwise you could have problems.

Petr_Kropotkin
15th January 2010, 16:17
I reinstalled and it ran . Now I get these errors:
CreateProcess(): Access is denied.

mingw32-make[1]: *** [debug/FindDialog.o] Error 123
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project FindDialog
When executing build step 'Make'

I thought it might have occured when I configured Comodo Firewall to accept all signals from environment. I get these erros when I ran th address program too. I reinstalled and still got 'em . Help !Q

JD2000
15th January 2010, 18:39
Interesting, the CreateProcess() message is actually generated by Windows not QT.

It usually means that there is a problem using long filenames, what version of Windows are you running, have you installed all the service packs?

You could try putting quotes around your file names, or make sure that they are unique upto any spaces.

A typical culprit that causes this error is "Program".
Versions of Windows that suffer from this problem can not tell the difference between "Program files", "Program folders" etc unless they are quoted.

Petr_Kropotkin
16th January 2010, 13:45
I have XP PRO with all the service packs installed

JD2000
18th January 2010, 19:09
Did you get any other output?

I believe that error 123 signifies that there is something wrong with a Volume, Folder or File name and
error 2 means that something (probably a file) can not be found.

Do any of the paths contain Unix style '/' instead of '\' ?

squidge
18th January 2010, 19:50
If those are Windows error codes, then http://msdn.microsoft.com/en-us/library/ms681382%28VS.85%29.aspx

ERROR_INVALID_NAME
123 (0x7B)
The filename, directory name, or volume label syntax is incorrect.

ERROR_FILE_NOT_FOUND
2 (0x2)
The system cannot find the file specified.

Also, "debug/FindDialog.o" doesn't look like a valid path to me for a Windows OS.