Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / C++ [игнор отключен] [закрыт для гостей] / (Qt) Помогите найти ошибку. / 18 сообщений из 18, страница 1 из 1
20.05.2005, 15:34
    #33077468
Sarin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Этот код я целиком содрал с книги по Qt. Выполнил qmake. А при попытке make вылазят ошибки.
Создаётся впечатление, что moc не выполняется.

Вот finddialog.h:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
#ifdef FINDDIALOG_H
#define FINDDIALOG_H
#include <qdialog.h>

class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;

class FindDialog: public QDialog{
	Q_OBJECT
	public:
		FindDialog(QWidget *parent =  0 , const char *name =  0 );
	signals:
		void findNext(const QString &str, bool caseSensitive);
		void findPrev(const QString &str, bool caseSensitive);
	private slots:
		void findCliced();
		void enableFindButton(const QString &text);
	private:
		QLabel *label;
		QLineEdit *lineEdit;
		QCheckBox *caseCheckBox, *backwardCheckBox;
		QPushButton *findButton, closeButton;
};
#endif
Вот finddialog.cpp:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qpushbutton.h>

#include "finddialog.h"

FindDialog::FindDialog(QWidget *parent, const char *name): QDialog(parent, name){
	setCaption(tr("Find"));
	label = new QLabel(tr("Find &what:"), this);
	lineEdit = new QlineEdit(this);
	label->setBuddy(lineEdit);
	caseCheckBox = new QCheckBox(tr("Match &case"), this);
	backwardCheckBox = new QCheckBox(tr("Search &backward"), this);
	findButton = new QPushButton(tr("&Find"), this);
	findButton->setDefault(true);
	findButton->setEnabled(false);
	closeButton = new QPushButton(tr("Close"), this);
	connect(lineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(enableFindButton(const QString &)));
	connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked()));
	connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
	QHBoxLayout *topLeftLayout = new QHBoxLayout;
	topLeftLayout->addWidget(label);
	topLeftLayout->addWidget(lineEdit);
	QVBoxLayout *leftLayout = new QVBoxLayout;
	leftLayout->addLayout(topLeftLayout); 
	leftLayout->addWidget(caseCheckBox); 
	leftLayout->addWidget(backwardCheckBox); 
	QVBoxLayout *rightLayout = new QVBoxLayout; 
	rightLayout->addWidget(findButton); 
	rightLayout->addWidget(closeButton); 
	rightLayout->addStretch( 1 ); 
	QHBoxLayout *mainLayout = new QHBoxLayout(this); 
	mainLayout->setMargin( 11 );
	mainLayout->setSpacing( 6 ); 
	mainLayout->addLayout(leftLayout); 
	mainLayout->addLayout(rightLayout); 
}

void FindDialog::findClicked(){
	QString text = lineEdit->text(); 
	bool caseSensitive = caseCheckBox->isOn(); 
	if (backwardCheckBox->isOn()) 
		emit findPrev(text, caseSensitive); 
	else 
		emit findNext(text, caseSensitive);
}

void FindDialog::enableFindButton(const QString &text) { 
	findButton->setEnabled(!text.isEmpty()); 
}

А вот ошибки:

$ make
g++ -c -pipe -Wall -W -pipe -Wall -O2 -march=i586 -mcpu=i686 -DGLX_GLXEXT_LEGACY -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/lib/qt3//include -o finddialog.o finddialog.cpp
In file included from finddialog.cpp:7:
finddialog.h:26:7: warning: no newline at end of file
finddialog.cpp:9: error: syntax error before `::' token
finddialog.cpp:11: error: ISO C++ forbids declaration of `label' with no type
finddialog.cpp:11: error: `tr' was not declared in this scope
finddialog.cpp:11: error: invalid use of `this' at top level
finddialog.cpp:12: error: ISO C++ forbids declaration of `lineEdit' with no type
finddialog.cpp:12: error: syntax error before `(' token
finddialog.cpp:13: error: syntax error before `->' token
finddialog.cpp:14: error: ISO C++ forbids declaration of `caseCheckBox' with no type
finddialog.cpp:14: error: `tr' was not declared in this scope
finddialog.cpp:14: error: invalid use of `this' at top level
finddialog.cpp:15: error: ISO C++ forbids declaration of `backwardCheckBox' with no type
finddialog.cpp:15: error: `tr' was not declared in this scope
finddialog.cpp:15: error: invalid use of `this' at top level
finddialog.cpp:16: error: ISO C++ forbids declaration of `findButton' with no type
finddialog.cpp:16: error: `tr' was not declared in this scope
finddialog.cpp:16: error: invalid use of `this' at top level
finddialog.cpp:17: error: syntax error before `->' token
finddialog.cpp:18: error: syntax error before `->' token
finddialog.cpp:19: error: ISO C++ forbids declaration of `closeButton' with no type
finddialog.cpp:19: error: `tr' was not declared in this scope
finddialog.cpp:19: error: invalid use of `this' at top level
finddialog.cpp:20: error: invalid use of `this' at top level
finddialog.cpp:20: error: ISO C++ forbids declaration of `connect' with no type
finddialog.cpp:20: error: initializer list being treated as compound expression
finddialog.cpp:21: error: invalid use of `this' at top level
finddialog.cpp:21: error: ISO C++ forbids declaration of `connect' with no type
finddialog.cpp:21: error: redefinition of `int connect'
finddialog.cpp:20: error: `int connect' previously defined here
finddialog.cpp:21: error: initializer list being treated as compound expression
finddialog.cpp:22: error: invalid use of `this' at top level
finddialog.cpp:22: error: ISO C++ forbids declaration of `connect' with no type
finddialog.cpp:22: error: redefinition of `int connect'
finddialog.cpp:21: error: `int connect' previously defined here
finddialog.cpp:22: error: initializer list being treated as compound expression
finddialog.cpp:24: error: syntax error before `->' token
finddialog.cpp:25: error: syntax error before `->' token
finddialog.cpp:27: error: syntax error before `->' token
finddialog.cpp:28: error: syntax error before `->' token
finddialog.cpp:29: error: syntax error before `->' token
finddialog.cpp:31: error: syntax error before `->' token
finddialog.cpp:32: error: syntax error before `->' token
finddialog.cpp:33: error: syntax error before `->' token
finddialog.cpp:34: error: invalid use of `this' at top level
finddialog.cpp:35: error: syntax error before `->' token
finddialog.cpp:36: error: syntax error before `->' token
finddialog.cpp:37: error: syntax error before `->' token
finddialog.cpp:38: error: syntax error before `->' token
finddialog.cpp:41: error: syntax error before `::' token
finddialog.cpp:43: error: base operand of `->' is not a pointer
finddialog.cpp:44: error: syntax error before `if'
finddialog.cpp:50: error: syntax error before `::' token
{standard input}: Assembler messages:
{standard input}:49: Error: symbol `connect' is already defined
{standard input}:55: Error: symbol `connect' is already defined
make: *** [finddialog.o] Ошибка 1
...
Рейтинг: 0 / 0
21.05.2005, 00:48
    #33078259
(Qt) Помогите найти ошибку.
Не #ifdef ,а #ifndef
...
Рейтинг: 0 / 0
21.05.2005, 07:58
    #33078330
Sarin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
А в ответ

make
g++ -c -pipe -Wall -W -pipe -Wall -O2 -march=i586 -mcpu=i686 -DGLX_GLXEXT_LEGACY -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/lib/qt3//include -o finddialog.o finddialog.cpp
In file included from finddialog.cpp:7:
finddialog.h:26:7: warning: no newline at end of file
finddialog.cpp: In constructor `FindDialog::FindDialog(QWidget*, const char*)':
finddialog.cpp:9: error: no matching function for call to `QPushButton::QPushButton()'
/usr/lib/qt3/include/qpushbutton.h:138: error: candidates are: QPushButton::QPushButton(const QPushButton&)
/usr/lib/qt3/include/qpushbutton.h:67: error: QPushButton::QPushButton(const QIconSet&, const QString&, QWidget*, const char*)
/usr/lib/qt3/include/qpushbutton.h:65: error: QPushButton::QPushButton(const QString&, QWidget*, const char*)
/usr/lib/qt3/include/qpushbutton.h:64: error: QPushButton::QPushButton(QWidget*, const char*)
finddialog.cpp:10: error: syntax error before `public'
finddialog.cpp: At global scope:
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: non-member function `const char* className()' cannot have `const' method qualifier
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp: In function `QObject* qObject()':
finddialog.cpp:10: error: invalid use of `this' in non-member function
finddialog.cpp: At global scope:
finddialog.cpp:10: error: syntax error before `private'
finddialog.cpp:11: error: ISO C++ forbids declaration of `setCaption' with no type
finddialog.cpp:11: error: invalid conversion from `const char*' to `int'
finddialog.cpp:12: error: ISO C++ forbids declaration of `label' with no type
finddialog.cpp:12: error: invalid use of `this' at top level
finddialog.cpp:13: error: ISO C++ forbids declaration of `lineEdit' with no type
finddialog.cpp:13: error: syntax error before `(' token
finddialog.cpp:14: error: syntax error before `->' token
finddialog.cpp:15: error: ISO C++ forbids declaration of `caseCheckBox' with no type
finddialog.cpp:15: error: invalid use of `this' at top level
finddialog.cpp:16: error: ISO C++ forbids declaration of `backwardCheckBox' with no type
finddialog.cpp:16: error: invalid use of `this' at top level
finddialog.cpp:17: error: ISO C++ forbids declaration of `findButton' with no type
finddialog.cpp:17: error: invalid use of `this' at top level
finddialog.cpp:18: error: syntax error before `->' token
finddialog.cpp:19: error: syntax error before `->' token
finddialog.cpp:20: error: ISO C++ forbids declaration of `closeButton' with no type
finddialog.cpp:20: error: invalid use of `this' at top level
finddialog.cpp:21: error: invalid use of `this' at top level
finddialog.cpp:21: error: ISO C++ forbids declaration of `connect' with no type
finddialog.cpp:21: error: initializer list being treated as compound expression
finddialog.cpp:22: error: invalid use of `this' at top level
finddialog.cpp:22: error: ISO C++ forbids declaration of `connect' with no type
finddialog.cpp:22: error: redefinition of `int connect'
finddialog.cpp:21: error: `int connect' previously defined here
finddialog.cpp:22: error: initializer list being treated as compound expression
finddialog.cpp:23: error: invalid use of `this' at top level
finddialog.cpp:23: error: ISO C++ forbids declaration of `connect' with no type
finddialog.cpp:23: error: redefinition of `int connect'
finddialog.cpp:22: error: `int connect' previously defined here
finddialog.cpp:23: error: initializer list being treated as compound expression
finddialog.cpp:25: error: syntax error before `->' token
finddialog.cpp:26: error: syntax error before `->' token
finddialog.cpp:28: error: syntax error before `->' token
finddialog.cpp:29: error: syntax error before `->' token
finddialog.cpp:30: error: syntax error before `->' token
finddialog.cpp:32: error: syntax error before `->' token
finddialog.cpp:33: error: syntax error before `->' token
finddialog.cpp:34: error: syntax error before `->' token
finddialog.cpp:35: error: invalid use of `this' at top level
finddialog.cpp:36: error: syntax error before `->' token
finddialog.cpp:37: error: syntax error before `->' token
finddialog.cpp:38: error: syntax error before `->' token
finddialog.cpp:39: error: syntax error before `->' token
finddialog.cpp:42: error: no `void FindDialog::findClicked()' member function declared in class `FindDialog'
finddialog.cpp:10: warning: `bool qt_static_property(QObject*, int, int, QVariant*)' declared `static' but never defined
finddialog.cpp:10: warning: `QMetaObject* staticMetaObject()' declared `static' but never defined
finddialog.cpp:10: warning: `QString tr(const char*, const char*)' declared `static' but never defined
finddialog.cpp:10: warning: `QString trUtf8(const char*, const char*)' declared `static' but never defined
{standard input}: Assembler messages:
{standard input}:55: Error: symbol `connect' is already defined
{standard input}:61: Error: symbol `connect' is already defined
make: *** [finddialog.o] Ошибка 1
...
Рейтинг: 0 / 0
21.05.2005, 08:00
    #33078331
Sarin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Особенно порадовала finddialog.cpp:10: error: syntax error before `public'
Где там public?
...
Рейтинг: 0 / 0
21.05.2005, 12:27
    #33078420
(Qt) Помогите найти ошибку.
1)
Вместо
QPushButton *findButton, closeButton ;
Очевидно должно быть
QPushButton *findButton, *closeButton ;

===что следует с одной стороны из сообщений :
finddialog.cpp:9: error: no matching function for call to `QPushButton::QPushButton()'
/usr/lib/qt3/include/qpushbutton.h:138: error: candidates are: QPushButton::QPushButton(const QPushButton&)
/usr/lib/qt3/include/qpushbutton.h:67: error: QPushButton::QPushButton(const QIconSet&, const QString&, QWidget*, const char*)
/usr/lib/qt3/include/qpushbutton.h:65: error: QPushButton::QPushButton(const QString&, QWidget*, const char*)
/usr/lib/qt3/include/qpushbutton.h:64: error: QPushButton::QPushButton(QWidget*, const char*)

(т.е. конструктор FindDialog не может проинициализировать член closeButton не имея для него ( closeButton ) конструктора без параметров)

===и из кода с другой
closeButton = new QPushButton(tr("Close"), this);

2)По поводу public
В файле finddialog.cpp есть директива #include "finddialog.h" препроцессора ( прекомпилятора )
Поэтому к компилятору файл finddialog.cpp попадает с уже "вставленным во
внуть" finddialog.h в котором есть public.
...
Рейтинг: 0 / 0
22.05.2005, 00:02
    #33078854
Sarin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Исправил. Ошибки другими стали. Всё постить не буду. Вот давай с этим разберёмся:
finddialog.cpp: In constructor `FindDialog::FindDialog(QWidget*, const char*)':
finddialog.cpp:10: error: syntax error before `public'
finddialog.cpp: At global scope:
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: non-member function `const char* className()' cannot have `const' method qualifier
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: virtual outside class declaration

ЗЫ: извини, что отвлекаю. Просто я в С++ новичёк. Мне помощь нужна.
...
Рейтинг: 0 / 0
24.05.2005, 21:14
    #33082961
Землекоп
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Еще есть
lineEdit = new QlineEdit(this);
должно быть lineEdit = new QLineEdit(this);


в finddialog.h

void findCliced();
должно быть
void findClicked();
...
Рейтинг: 0 / 0
27.05.2005, 08:31
    #33086536
Void666
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Обрати внимание

finddialog.h:26:7: warning: no newline at end of file

исправь сначало это.
...
Рейтинг: 0 / 0
27.05.2005, 08:52
    #33086573
Землекоп
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Void666Обрати внимание

finddialog.h:26:7: warning: no newline at end of file

исправь сначало это.

маловероятно, что это может влиять на что-либо
...
Рейтинг: 0 / 0
27.05.2005, 09:06
    #33086582
Void666
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Землекоп Void666Обрати внимание

finddialog.h:26:7: warning: no newline at end of file

исправь сначало это.

маловероятно, что это может влиять на что-либо

Ну почему же, смотрим лог, сначала идет

finddialog.h:26:7: warning: no newline at end of file

затем

finddialog.cpp:9: error: syntax error before `::' token

Явно, компилятор врет, т.к. с синтаксисом там все окей, следовательно был
не корректно обработан хидер файл, рыть нужно варнинг.
...
Рейтинг: 0 / 0
27.05.2005, 09:17
    #33086605
Землекоп
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Void666 Землекоп Void666Обрати внимание

finddialog.h:26:7: warning: no newline at end of file

исправь сначало это.

маловероятно, что это может влиять на что-либо

Ну почему же, смотрим лог, сначала идет

finddialog.h:26:7: warning: no newline at end of file

затем

finddialog.cpp:9: error: syntax error before `::' token

Явно, компилятор врет, т.к. с синтаксисом там все окей, следовательно был
не корректно обработан хидер файл, рыть нужно варнинг.

После исправлений, которые я дал чуть выше, все нормально компилиться. Там много наведенных ошибок.
...
Рейтинг: 0 / 0
27.05.2005, 13:24
    #33087415
Sarin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Ошибки продолжаются.
Землекоп, а ты можешь кинуть сюда сои файлы, если ты их собирал. Попробую пересобрать.

Вот ошибки:
[sarin@localhost findDialog]$ make
g++ -c -pipe -Wall -W -pipe -Wall -O2 -march=i586 -mcpu=i686 -DGLX_GLXEXT_LEGACY -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/lib/qt3//include -o finddialog.o finddialog.cpp
finddialog.cpp: In constructor `FindDialog::FindDialog(QWidget*, const char*)':
finddialog.cpp:10: error: syntax error before `public'
finddialog.cpp: At global scope:
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: non-member function `const char* className()' cannot have `const' method qualifier
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp:10: error: virtual outside class declaration
finddialog.cpp: In function `QObject* qObject()':
finddialog.cpp:10: error: invalid use of `this' in non-member function
finddialog.cpp: At global scope:
finddialog.cpp:10: error: syntax error before `private'
finddialog.cpp:11: error: ISO C++ forbids declaration of `setCaption' with no type
finddialog.cpp:11: error: invalid conversion from `const char*' to `int'
finddialog.cpp:12: error: ISO C++ forbids declaration of `label' with no type
finddialog.cpp:12: error: invalid use of `this' at top level
finddialog.cpp:13: error: ISO C++ forbids declaration of `lineEdit' with no type
finddialog.cpp:13: error: invalid use of `this' at top level
finddialog.cpp:14: error: syntax error before `->' token
finddialog.cpp:15: error: ISO C++ forbids declaration of `caseCheckBox' with no type
finddialog.cpp:15: error: invalid use of `this' at top level
finddialog.cpp:16: error: ISO C++ forbids declaration of `backwardCheckBox' with no type
finddialog.cpp:16: error: invalid use of `this' at top level
finddialog.cpp:17: error: ISO C++ forbids declaration of `findButton' with no type
finddialog.cpp:17: error: invalid use of `this' at top level
finddialog.cpp:18: error: syntax error before `->' token
finddialog.cpp:19: error: syntax error before `->' token
finddialog.cpp:20: error: ISO C++ forbids declaration of `closeButton' with no type
finddialog.cpp:20: error: invalid use of `this' at top level
finddialog.cpp:21: error: invalid use of `this' at top level
finddialog.cpp:21: error: ISO C++ forbids declaration of `connect' with no type
finddialog.cpp:21: error: initializer list being treated as compound expression
finddialog.cpp:22: error: invalid use of `this' at top level
finddialog.cpp:22: error: ISO C++ forbids declaration of `connect' with no type
finddialog.cpp:22: error: redefinition of `int connect'
finddialog.cpp:21: error: `int connect' previously defined here
finddialog.cpp:22: error: initializer list being treated as compound expression
finddialog.cpp:23: error: invalid use of `this' at top level
finddialog.cpp:23: error: ISO C++ forbids declaration of `connect' with no type
finddialog.cpp:23: error: redefinition of `int connect'
finddialog.cpp:22: error: `int connect' previously defined here
finddialog.cpp:23: error: initializer list being treated as compound expression
finddialog.cpp:25: error: syntax error before `->' token
finddialog.cpp:26: error: syntax error before `->' token
finddialog.cpp:28: error: syntax error before `->' token
finddialog.cpp:29: error: syntax error before `->' token
finddialog.cpp:30: error: syntax error before `->' token
finddialog.cpp:32: error: syntax error before `->' token
finddialog.cpp:33: error: syntax error before `->' token
finddialog.cpp:34: error: syntax error before `->' token
finddialog.cpp:35: error: invalid use of `this' at top level
finddialog.cpp:36: error: syntax error before `->' token
finddialog.cpp:37: error: syntax error before `->' token
finddialog.cpp:38: error: syntax error before `->' token
finddialog.cpp:39: error: syntax error before `->' token
finddialog.cpp:10: warning: `bool qt_static_property(QObject*, int, int, QVariant*)' declared `static' but never defined
finddialog.cpp:10: warning: `QMetaObject* staticMetaObject()' declared `static' but never defined
finddialog.cpp:10: warning: `QString tr(const char*, const char*)' declared `static' but never defined
finddialog.cpp:10: warning: `QString trUtf8(const char*, const char*)' declared `static' but never defined
{standard input}: Assembler messages:
{standard input}:55: Error: symbol `connect' is already defined
{standard input}:61: Error: symbol `connect' is already defined
make: *** [finddialog.o] Ошибка 1
...
Рейтинг: 0 / 0
27.05.2005, 14:07
    #33087563
Землекоп
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Я собирал под MS VC++ 6.0, но особой разницы быть не должно.

finddialog.h

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
#ifndef FINDDIALOG_H
#define FINDDIALOG_H
#include <qdialog.h>

class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;

class FindDialog: public QDialog{
	Q_OBJECT
	public:
		FindDialog(QWidget *parent =  0 , const char *name =  0 );
	signals:
		void findNext(const QString &str, bool caseSensitive);
		void findPrev(const QString &str, bool caseSensitive);
	private slots:
		void findClicked();
		void enableFindButton(const QString &text);
	private:
		QLabel *label;
		QLineEdit *lineEdit;
		QCheckBox *caseCheckBox, *backwardCheckBox;
		QPushButton *findButton, *closeButton;
};
#endif


finddialog.cpp

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qpushbutton.h>

#include "finddialog.h"

FindDialog::FindDialog(QWidget *parent, const char *name): QDialog(parent, name){
	setCaption(tr("Find"));
	label = new QLabel(tr("Find &what:"), this);
	lineEdit = new QLineEdit(this);
	label->setBuddy(lineEdit);
	caseCheckBox = new QCheckBox(tr("Match &case"), this);
	backwardCheckBox = new QCheckBox(tr("Search &backward"), this);
	findButton = new QPushButton(tr("&Find"), this);
	findButton->setDefault(true);
	findButton->setEnabled(false);
	closeButton = new QPushButton(tr("Close"), this);
	connect(lineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(enableFindButton(const QString &)));
	connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked()));
	connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
	QHBoxLayout *topLeftLayout = new QHBoxLayout;
	topLeftLayout->addWidget(label);
	topLeftLayout->addWidget(lineEdit);
	QVBoxLayout *leftLayout = new QVBoxLayout;
	leftLayout->addLayout(topLeftLayout); 
	leftLayout->addWidget(caseCheckBox); 
	leftLayout->addWidget(backwardCheckBox); 
	QVBoxLayout *rightLayout = new QVBoxLayout; 
	rightLayout->addWidget(findButton); 
	rightLayout->addWidget(closeButton); 
	rightLayout->addStretch( 1 ); 
	QHBoxLayout *mainLayout = new QHBoxLayout(this); 
	mainLayout->setMargin( 11 );
	mainLayout->setSpacing( 6 ); 
	mainLayout->addLayout(leftLayout); 
	mainLayout->addLayout(rightLayout); 
}

void FindDialog::findClicked(){
	QString text = lineEdit->text(); 
	bool caseSensitive = caseCheckBox->isOn(); 
	if (backwardCheckBox->isOn()) 
		emit findPrev(text, caseSensitive); 
	else 
		emit findNext(text, caseSensitive);
}

void FindDialog::enableFindButton(const QString &text) { 
	findButton->setEnabled(!text.isEmpty()); 
}


...
Рейтинг: 0 / 0
27.05.2005, 14:25
    #33087625
v6y
v6y
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
finddialog.h
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
#ifndef FINDDIALOG_H
#define FINDDIALOG_H
#include <qdialog.h>

class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;

class FindDialog: public QDialog{
        Q_OBJECT
        public:
                FindDialog(QWidget *parent =  0 , const char *name =  0 );
        signals:
                void findNext(const QString &str, bool caseSensitive);
                void findPrev(const QString &str, bool caseSensitive);
        private slots:
                void findClicked();
                void enableFindButton(const QString &text);
        private:
                QLabel *label;
                QLineEdit *lineEdit;
                QCheckBox *caseCheckBox, *backwardCheckBox;
                QPushButton *findButton, *closeButton;
};
#endif


finddialog.cpp
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qpushbutton.h>

#include "finddialog.h"

FindDialog::FindDialog(QWidget *parent, const char *name): QDialog(parent, name) {
        setCaption(tr("Find"));
        label = new QLabel(tr("Find &what:"), this);
        lineEdit = new QLineEdit(this);
        label->setBuddy(lineEdit);
        caseCheckBox = new QCheckBox(tr("Match &case"), this);
        backwardCheckBox = new QCheckBox(tr("Search &backward"), this);
        findButton = new QPushButton(tr("&Find"), this);
        findButton->setDefault(true);
        findButton->setEnabled(false);
        closeButton = new QPushButton(tr("Close"), this);
        connect(lineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(enableFindButton(const QString &)));
        connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked()));
        connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
        QHBoxLayout *topLeftLayout = new QHBoxLayout;
        topLeftLayout->addWidget(label);
        topLeftLayout->addWidget(lineEdit);
        QVBoxLayout *leftLayout = new QVBoxLayout;
        leftLayout->addLayout(topLeftLayout);
        leftLayout->addWidget(caseCheckBox);
        leftLayout->addWidget(backwardCheckBox);
        QVBoxLayout *rightLayout = new QVBoxLayout;
        rightLayout->addWidget(findButton);
        rightLayout->addWidget(closeButton);
        rightLayout->addStretch( 1 );
        QHBoxLayout *mainLayout = new QHBoxLayout(this);
        mainLayout->setMargin( 11 );
        mainLayout->setSpacing( 6 );
        mainLayout->addLayout(leftLayout);
        mainLayout->addLayout(rightLayout);
}

void FindDialog::findClicked(){
        QString text = lineEdit->text();
        bool caseSensitive = caseCheckBox->isOn();
        if (backwardCheckBox->isOn())
                emit findPrev(text, caseSensitive);
        else
                emit findNext(text, caseSensitive);
}

void FindDialog::enableFindButton(const QString &text) {
        findButton->setEnabled(!text.isEmpty());
}

А вот этого файла у тебя нет:
main.cpp
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
#include "finddialog.h"
#include <qapplication.h>

int main( int argc, char **argv )
{
    QApplication a( argc, argv );
    FindDialog *fd = new FindDialog();
    a.setMainWidget( fd );
    fd->show();
    int result = a.exec();
    delete fd;
    return result;
}

А это скриншот того что должно получится
...
Рейтинг: 0 / 0
27.05.2005, 14:43
    #33087681
Землекоп
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
...
Рейтинг: 0 / 0
27.05.2005, 14:48
    #33087692
Землекоп
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Под Windows
...
Рейтинг: 0 / 0
27.05.2005, 14:56
    #33087714
Sarin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Последнее собралось. Значит дело в моих кривых руках.

Но вот проблема: в каталоге где я собирал бинарника не получилось. А получился пустой документ в 0 байт, при клике на котором запускается прога. Где бинарник? Поиск не помог.
...
Рейтинг: 0 / 0
27.05.2005, 14:59
    #33087728
Sarin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(Qt) Помогите найти ошибку.
Нашлось. Наверное make файл пустой создал, а конкверрор решил, что больше ничего не будет:)

Вот и мой скрин:
...
Рейтинг: 0 / 0
Форумы / C++ [игнор отключен] [закрыт для гостей] / (Qt) Помогите найти ошибку. / 18 сообщений из 18, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]