[Qt-interest] Help with basic program
john doe
thebiggestbangtheory at gmail.com
Tue Sep 1 00:31:36 CEST 2009
Hello all,
Very basic question:
I have a small GUI, made via QT, with the following code
mainwindowimpl.h
[code]
#ifndef MAINWINDOWIMPL_H
#define MAINWINDOWIMPL_H
//
#include <QFileDialog>
#include <QDialog>
#include <QMainWindow>
#include "ui_mainwindow.h"
//
class MainWindowImpl : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
MainWindowImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
public slots:
void getPathdir(void);
};
#endif
[/code]
mainwindowimpl.cpp
[code[
#include <QtGui>
#include "mainwindowimpl.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include <QThread>
using namespace std;
//
MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
: QMainWindow(parent, f)
{
setupUi(this);
//signals and slots are now being connected
connect( logfileloc_pushButton, SIGNAL( clicked() ), this, SLOT(
getPathdir() ) );
}
//
//This function allows for the user to
//select a path to any directory
void MainWindowImpl::getPathdir(void)
{
QString path;
path = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
"/home",
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
//set the text of the text box to the path of the file
bufloc_linedit->setText( path );
}
[/code]
in main.cpp
[code]
#include <QApplication>
#include "mainwindowimpl.h"
//
int main(int argc, char ** argv)
{
QApplication app( argc, argv );
MainWindowImpl win;
win.show();
app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}
[/code]
I am using QDevelop as my IDE and I gt the following error
src/mainwindowimpl.cpp:40: error: ‘bufloc_linedit’ is not a member of
‘MainWindowImpl’
However, mainwindowimpl.h is included in the cpp file and the .h file does
include the ui_mainwindow.h file which actually contains the declaration of
bufloc_lineedit like so
[code]
class Ui_MainWindow
{
public:
QPushButton *bufloc_pushButton;
QLineEdit *bufloc_lineEdit;
[/code]
I am not a c++ expert can someone please let me have a pointer as to what
the error is.
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090831/f1177488/attachment.html
More information about the Qt-interest-old
mailing list