[Çözüldü] Qt Derleme İşlemi Olmuyor, QDialog Bulunanamadı Diyor

Başlatan exclipit, 24 Temmuz 2014 - 18:17:23

« önceki - sonraki »

0 Üyeler ve 1 Ziyaretçi konuyu incelemekte.

exclipit

Kodları okumadan önce sayfanın en altına inip derleme hatalarına bakabilirsiniz.
Şimdi derlemeye çalıştığım kodları yazmadan önce, berteyim ki bu kodlar "Qt 4 İle C++ GUI Programlama" kitabındaki gibidir, oradaki kodları izleyerek tekrardan yazıp derlemeye çalıştım.



finddialog.h dosyası:
#ifndef FINDDIALOG_H
#define FINDDIALOG_H

#include <QDialog>

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

class FindDialog : public QDialog{
Q_OBJECT

public:
FindDialog(QWidget *parent = 0);

signals:
void findNext(const QString &str, Qt::CaseSensivity cs);
void findPrevious(const QString &str, Qt::CaseSensivity);

private slots:
void findClicked();
void enableFindButton(const QString &text);

private:
QLabel *label;
QLineEdit *lineedit;
QCheckBox *caseCheckBox;
QCheckBox *backwardCheckBox;
QPushButton *findButton;
QPushButton *closeButton;
};

#endif





finddialog.cpp dosyası:
#include <QtGui>
#include "finddialog.h"

FindDialog::FindDialog(QWidget *parent) : QDialog(parent)
{
label = new QLabel(tr("Find &what:"));
lineEdit = new QLineEdit;
label -> setBuddy("lineEdit");

caseCheckBox = new QCheckBox(tr("Match &case"));
backwardCheckBox = bew QChackBox(tr("Search &backward"));

findButton = new QPushButtno(tr("&Find"));
findButton ->setDefault(true);
findButton -> setEnabled(false);

closeButton = new QPushButton(tr("Close"));

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 *righLayout = new QVBoxLayout;
rightLayout->addWidget(findButton);
rightLayout->addWidget(closeButton);
rightLayout->addStretch();

QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setLayout(mainLayout);

setWindowTitle(tr("Find"));
setFixedHeight(sizeHint().height());

}

void FindDialog::findClicked(){
QString text = lineEdit->text();
Qt::CaseSensivity cs = caseCheckBox->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive;

if (backwardCheckBox->isChecked()) {
emit findPrevious(text, cs);
} else {
emit findNext(text, cs);
}
}

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






main.cpp dosyası:

#include <QApplication>
#include "finddialog.h"
int main(int argc, char *argv[])
{

QApplication app(argc, argv);

FindDialog *dialog = new FindDialog;

dialog->show();

return app.exec();
}


Bunların olduğu dizine gelip şu komutları verdim:

umut@exclipit:~/qt/qtdialog$ qmake -project
umut@exclipit:~/qt/qtdialog$ qmake
umut@exclipit:~/qt/qtdialog$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -I. -I/usr/include/qt5 -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -o finddialog.o finddialog.cpp
In file included from finddialog.cpp:2:0:
finddialog.h:4:19: fatal error: QDialog: Böyle bir dosya ya da dizin yok
#include <QDialog>
                   ^
compilation terminated.
make: *** [finddialog.o] Hata 1


Ve bana bu hataları verdi. Makefile ve proje dosyalarını silip tekrardan şu komutlarla yine derlemeyi denedim:

umut@exclipit:~/qt/qtdialog$ qmake-qt4 -project
umut@exclipit:~/qt/qtdialog$ qmake-qt4
umut@exclipit:~/qt/qtdialog$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o finddialog.o finddialog.cpp
In file included from finddialog.cpp:2:0:
finddialog.h:18:41: error: 'Qt::CaseSensivity' has not been declared
   void findNext(const QString &str, Qt::CaseSensivity cs);
                                         ^
finddialog.h:19:45: error: 'Qt::CaseSensivity' has not been declared
   void findPrevious(const QString &str, Qt::CaseSensivity);
                                             ^
finddialog.cpp: In constructor 'FindDialog::FindDialog(QWidget*)':
finddialog.cpp:7:2: error: 'lineEdit' was not declared in this scope
  lineEdit = new QLineEdit;
  ^
finddialog.cpp:8:30: error: no matching function for call to 'QLabel::setBuddy(const char [9])'
  label -> setBuddy("lineEdit");
                              ^
finddialog.cpp:8:30: note: candidate is:
In file included from /usr/include/qt4/QtGui/QtGui:168:0,
                 from finddialog.cpp:1:
/usr/include/qt4/QtGui/qlabel.h:105:10: note: void QLabel::setBuddy(QWidget*)
     void setBuddy(QWidget *);
          ^
/usr/include/qt4/QtGui/qlabel.h:105:10: note:   no known conversion for argument 1 from 'const char [9]' to 'QWidget*'
finddialog.cpp:11:21: error: 'bew' was not declared in this scope
  backwardCheckBox = bew QChackBox(tr("Search &backward"));
                     ^
finddialog.cpp:11:25: error: expected ';' before 'QChackBox'
  backwardCheckBox = bew QChackBox(tr("Search &backward"));
                         ^
finddialog.cpp:13:19: error: expected type-specifier before 'QPushButtno'
  findButton = new QPushButtno(tr("&Find"));
                   ^
finddialog.cpp:13:19: error: expected ';' before 'QPushButtno'
finddialog.cpp:33:2: error: 'rightLayout' was not declared in this scope
  rightLayout->addWidget(findButton);
  ^
finddialog.cpp:32:15: warning: unused variable 'righLayout' [-Wunused-variable]
  QVBoxLayout *righLayout = new QVBoxLayout;
               ^
finddialog.cpp: In member function 'void FindDialog::findClicked()':
finddialog.cpp:48:18: error: 'lineEdit' was not declared in this scope
   QString text = lineEdit->text();
                  ^
finddialog.cpp:49:3: error: 'CaseSensivity' is not a member of 'Qt'
   Qt::CaseSensivity cs = caseCheckBox->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive;
   ^
finddialog.cpp:49:21: error: expected ';' before 'cs'
   Qt::CaseSensivity cs = caseCheckBox->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive;
                     ^
finddialog.cpp:52:26: error: 'cs' was not declared in this scope
  emit findPrevious(text, cs);
                          ^
finddialog.cpp:54:23: error: 'cs' was not declared in this scope
   emit findNext(text, cs);
                       ^
make: *** [finddialog.o] Hata 1


Sizce hata nerede olabilir? Kitabın linkini de atayım: http://ufukuzun.files.wordpress.com/2014/03/qt-4-ile-cpp-gui-programlama1.pdf
Bu kitabı açıp 15. sayfaya göz atmaya başlayabilirsiniz.

Çalışan iki el, dua eden binlerce elden daha çok iş yapar. – Gene Roddenberry

7hr33l3t73r

#1
Asagidaki kodlari derleyerek calistirabilirsin.
Denenmistir.
finddialog.cpp

#include <QtGui>
#include "finddialog.h"
FindDialog::FindDialog(QWidget *parent)
: QDialog(parent)
{
label = new QLabel(tr("Find &what:"));
lineEdit = new QLineEdit;
label->setBuddy(lineEdit);

caseCheckBox = new QCheckBox(tr("Match &case"));
backwardCheckBox = new QCheckBox(tr("Search &backward"));

findButton = new QPushButton(tr("&Find"));
findButton->setDefault(true);
findButton->setEnabled(false);

closeButton = new QPushButton(tr("Close"));
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();

QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setLayout(mainLayout);
setWindowTitle(tr("Find"));
setFixedHeight(sizeHint().height());
}
void FindDialog::findClicked()
{
QString text = lineEdit->text();
Qt::CaseSensitivity cs =
caseCheckBox->isChecked() ? Qt::CaseSensitive
: Qt::CaseInsensitive;
if (backwardCheckBox->isChecked()) {
emit findPrevious(text, cs);
} else {
emit findNext(text, cs);
}
}

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

finddialog.h

#ifndef FINDDIALOG_H
#define FINDDIALOG_H

#include <QDialog>

class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;
class FindDialog : public QDialog
{
Q_OBJECT

public:
FindDialog(QWidget *parent = 0);
signals:
void findNext(const QString &str, Qt::CaseSensitivity cs);
void findPrevious(const QString &str, Qt::CaseSensitivity cs);
private slots:
void findClicked();
void enableFindButton(const QString &text);

private:
QLabel *label;
QLineEdit *lineEdit;
QCheckBox *caseCheckBox;
QCheckBox *backwardCheckBox;
QPushButton *findButton;
QPushButton *closeButton;
};

#endif

main.cpp

#include <QApplication> 
#include "finddialog.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
FindDialog *dialog = new FindDialog;
dialog->show();
return app.exec();
}


Qt4 ile derlerseniz sorun cikmayacaktir.
dc -e '[q]sa[ln0=aln256%Pln256/snlbx]sb207356256404211981204295703670388snlbxq'
https://www.getgnu.org/gnulinux/gnulinux-ipuclari/nasil-akillica-soru-sorulur.html

exclipit

Çalışan iki el, dua eden binlerce elden daha çok iş yapar. – Gene Roddenberry