PDA

View Full Version : I got them dialog box doldrums



Petr_Kropotkin
16th January 2010, 15:18
Here is the code:


main.cpp
#include <QApplication>
#include <QDialog>
#include "ui_gotocelldialog.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Ui::GoToCellDialog ui;
QDialog *dialog = new QDialog;
ui.setupUi(dialog);
dialog->show();
return app.exec();
}

gotocelldialog.h
#ifndef GOTOCELLDIALOG_H
#define GOTOCELLDIALOG_H
#include <QDialog>
#include "ui_gotocelldialog.h"
class GoToCellDialog : public QDialog, public Ui::GoToCellDialog
{
Q_OBJECT
public:
GoToCellDialog(QWidget *parent = 0);
private slots:
void on_lineEdit_textChanged();
};
#endif

gotocelldialog.cpp
#include <QtGui>
#include "gotocelldialog.h"
GoToCellDialog::GoToCellDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
lineEdit->setValidator(new QRegExpValidator(regExp, this));
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}


void GoToCellDialog::on_lineEdit_textChanged()
{
okButton->setEnabled(lineEdit->hasAcceptableInput());
}


Ui_GoToCellDialog.h
#ifndef GOTOCELLDIALOGMO5700_H
#define GOTOCELLDIALOGMO5700_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>

QT_BEGIN_NAMESPACE

class Ui_dialog
{
public:
QLabel *label;
QLineEdit *lineEdit;
QPushButton *pushButton;
QPushButton *pushButton_2;

void setupUi(QDialog *dialog)
{
if (dialog->objectName().isEmpty())
dialog->setObjectName(QString::fromUtf8("dialog"));
dialog->resize(354, 140);
label = new QLabel(dialog);
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(30, 30, 71, 16));
lineEdit = new QLineEdit(dialog);
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
lineEdit->setGeometry(QRect(100, 30, 211, 20));
pushButton = new QPushButton(dialog);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
pushButton->setGeometry(QRect(100, 100, 75, 23));
pushButton_2 = new QPushButton(dialog);
pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
pushButton_2->setGeometry(QRect(220, 100, 75, 23));

retranslateUi(dialog);

QMetaObject::connectSlotsByName(dialog);
} // setupUi

void retranslateUi(QDialog *dialog)
{
dialog->setWindowTitle(QApplication::translate("dialog", "Dialog", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("dialog", "Cell Number:", 0, QApplication::UnicodeUTF8));
pushButton->setText(QApplication::translate("dialog", "ok", 0, QApplication::UnicodeUTF8));
pushButton_2->setText(QApplication::translate("dialog", "Cancel", 0, QApplication::UnicodeUTF8));
} // retranslateUi

};

namespace Ui {
class dialog: public Ui_dialog {};
} // namespace Ui

QT_END_NAMESPACE

#endif // GOTOCELLDIALOGMO5700_H



These are the errors I get
main.cpp: In function 'int qMain(int, char**)':
main.cpp:7: error: 'GoToCellDialog' is not a member of 'Ui'
main.cpp:7: error: expected ';' before 'ui'
main.cpp:9: error: 'ui' was not declared in this scope

Help !













































[/CODE]

jpn
16th January 2010, 18:17
Looks like you named it "dialog", not "GoToCellDialog" (notice the objectName property in Designer).

Petr_Kropotkin
16th January 2010, 23:58
Problem solved....