powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / C++ [игнор отключен] [закрыт для гостей] / (Qt) Помогите найти ошибку.
18 сообщений из 18, страница 1 из 1
(Qt) Помогите найти ошибку.
    #33077468
Sarin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Этот код я целиком содрал с книги по 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
(Qt) Помогите найти ошибку.
    #33078259
Не #ifdef ,а #ifndef
...
Рейтинг: 0 / 0
(Qt) Помогите найти ошибку.
    #33078330
Sarin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
А в ответ

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
(Qt) Помогите найти ошибку.
    #33078331
Sarin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Особенно порадовала finddialog.cpp:10: error: syntax error before `public'
Где там public?
...
Рейтинг: 0 / 0
(Qt) Помогите найти ошибку.
    #33078420
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
(Qt) Помогите найти ошибку.
    #33078854
Sarin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Исправил. Ошибки другими стали. Всё постить не буду. Вот давай с этим разберёмся:
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
(Qt) Помогите найти ошибку.
    #33082961
Фотография Землекоп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Еще есть
lineEdit = new QlineEdit(this);
должно быть lineEdit = new QLineEdit(this);


в finddialog.h

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

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

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

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

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

маловероятно, что это может влиять на что-либо
...
Рейтинг: 0 / 0
(Qt) Помогите найти ошибку.
    #33086582
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
(Qt) Помогите найти ошибку.
    #33086605
Фотография Землекоп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
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
(Qt) Помогите найти ошибку.
    #33087415
Sarin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Ошибки продолжаются.
Землекоп, а ты можешь кинуть сюда сои файлы, если ты их собирал. Попробую пересобрать.

Вот ошибки:
[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
(Qt) Помогите найти ошибку.
    #33087563
Фотография Землекоп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Я собирал под 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
(Qt) Помогите найти ошибку.
    #33087625
Фотография v6y
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
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
(Qt) Помогите найти ошибку.
    #33087681
Фотография Землекоп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
...
Рейтинг: 0 / 0
(Qt) Помогите найти ошибку.
    #33087692
Фотография Землекоп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Под Windows
...
Рейтинг: 0 / 0
(Qt) Помогите найти ошибку.
    #33087714
Sarin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Последнее собралось. Значит дело в моих кривых руках.

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

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


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