You are not logged in.

  • "pieterprovoost" started this thread

Posts: 35

Location: Brugge, BE

  • Send private message

1

Wednesday, November 8th 2006, 2:43pm

problem with calculator form example

Hi,

I'm trying to make my own application based on the calculator form example, but I'm having some problems...

This is what I get:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
>make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `D:/work/ph/software/R data file constructio
n'
g++ -c -O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_D
LL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
 -I"C:/Qt/4.2.1/include/QtCore" -I"C:/Qt/4.2.1/include/QtCore" -I"C:/Qt/4.2.1/in
clude/QtGui" -I"C:/Qt/4.2.1/include/QtGui" -I"C:/Qt/4.2.1/include" -I"C:/Qt/4.2.
1/include/ActiveQt" -I"release" -I"." -I"c:\Qt\4.2.1\mkspecs\win32-g++" -o relea
se\datafileconstructor.o datafileconstructor.cpp
datafileconstructor.cpp: In constructor `datafileconstructor::datafileconstructo
r(QWidget*)':
datafileconstructor.cpp:7: error: no matching function for call to `Ui::datafile
constructor::setupUi(datafileconstructor* const)'
ui_datafileconstructor.h:38: note: candidates are: void Ui_datafileconstructor::
setupUi(QDialog*)
mingw32-make[1]: *** [release\datafileconstructor.o] Error 1
mingw32-make[1]: Leaving directory `D:/work/ph/software/R data file construction
'
mingw32-make: *** [release] Error 2


I tried using the advice given on http://www.qtforum.org/article/15574/No-…g-function.html (using QMainWindow), but that gives me:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
>make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `D:/work/ph/software/R data file constructio
n'
g++ -c -O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_D
LL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
 -I"C:/Qt/4.2.1/include/QtCore" -I"C:/Qt/4.2.1/include/QtCore" -I"C:/Qt/4.2.1/in
clude/QtGui" -I"C:/Qt/4.2.1/include/QtGui" -I"C:/Qt/4.2.1/include" -I"C:/Qt/4.2.
1/include/ActiveQt" -I"release" -I"." -I"c:\Qt\4.2.1\mkspecs\win32-g++" -o relea
se\main.o main.cpp
In file included from main.cpp:2:
datafileconstructor.h:8: error: expected class-name before '{' token
main.cpp: In function `int qMain(int, char**)':
main.cpp:8: error: 'class datafileconstructor' has no member named 'show'
mingw32-make[1]: *** [release\main.o] Error 1
mingw32-make[1]: Leaving directory `D:/work/ph/software/R data file construction
'
mingw32-make: *** [release] Error 2


This is my code:

datafileconstructor.pro

Source code

1
2
3
4
5
6
SOURCES     += main.cpp
SOURCES     += datafileconstructor.cpp
HEADERS     += datafileconstructor.h
FORMS       += datafileconstructor.ui
CONFIG      += release
TEMPLATE    = app


datafileconstructor.cpp

Source code

1
2
3
4
5
6
7
8
9
10
11
12
#include <QtGui>
#include "datafileconstructor.h"

datafileconstructor::datafileconstructor(QWidget *parent)
   : QMainWindow(parent)
{
   ui.setupUi(this);
}

void datafileconstructor::on_stations_valueChanged(int value)
{
}


datafileconstructor.h

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef DATAFILECONSTRUCTOR_H
#define DATAFILECONSTRUCTOR_H

#include "ui_datafileconstructor.h"

class datafileconstructor : public QMainWindow 
{
   Q_OBJECT

public:
   datafileconstructor(QWidget *parent = 0);

private slots:
   void on_stations_valueChanged(int value);

private:
   Ui::datafileconstructor ui;
};

#endif


main.cpp

Source code

1
2
3
4
5
6
7
8
9
10
#include <QApplication>
#include "datafileconstructor.h"

int main(int argc, char *argv[])
{
   QApplication app(argc, argv);
   datafileconstructor myconstructor;
   myconstructor.show();
   return app.exec();
}


Thank you!
Pieter

agallers11

Beginner

Posts: 55

Location: MD, US

Occupation: Programmer

  • Send private message

2

Wednesday, November 8th 2006, 3:43pm

RE: problem with calculator form example

I believe the problem is that in the Calculator example the calculator class, which i'm guessing you gutted and used to make your datafileconstructor class inherited from QDialog. So the ui_... file for it uses the fxn setupUI(QDialog*) rather than setupUI(QMainWindow*). Hope this helps.

  • "pieterprovoost" started this thread

Posts: 35

Location: Brugge, BE

  • Send private message

3

Wednesday, November 8th 2006, 3:58pm

But then my first version (before I changed QWidget to QMainWindow) should work, no?

Cheers
Pieter

agallers11

Beginner

Posts: 55

Location: MD, US

Occupation: Programmer

  • Send private message

4

Wednesday, November 8th 2006, 4:16pm

I was assuming the code provided was for the first compiler error you gave. could you possibly include all those files (for compiler error #1) as an attachment?

This post has been edited 1 times, last edit by "agallers11" (Nov 8th 2006, 4:16pm)


  • "pieterprovoost" started this thread

Posts: 35

Location: Brugge, BE

  • Send private message

5

Wednesday, November 8th 2006, 4:22pm

Sorry, I didn't mean to post the changed code...
pieterprovoost has attached the following file:
  • qt.zip (3 kB - 30 times downloaded - latest: Feb 6th 2011, 9:15am)

agallers11

Beginner

Posts: 55

Location: MD, US

Occupation: Programmer

  • Send private message

6

Wednesday, November 8th 2006, 6:22pm

The problem is that when trolltech made the calculator example they used a QDialog for the form file rather than a qwidget. (So now if you open up the form file with a text editor you'll see it thinks its a QDialog.) Thats why you get the error:

Source code

1
2
3
4
datafileconstructor.cpp:7: error: no matching function for call to `Ui::datafile
constructor::setupUi(datafileconstructor* const)'
ui_datafileconstructor.h:38: note: candidates are: void Ui_datafileconstructor::
setupUi(QDialog*)


I'd suggest just creating a project and then copy-pasting your main.cpp, datafileconstructor.h & .cpp stuff in, and then remaking the form. (if you don't want to manually remake all widgets in the form you can actually open your 'old' form file and copy paste everything from it into your new one). good luck.

This post has been edited 1 times, last edit by "agallers11" (Nov 8th 2006, 6:22pm)


  • "pieterprovoost" started this thread

Posts: 35

Location: Brugge, BE

  • Send private message

7

Wednesday, November 8th 2006, 9:18pm

It works now, thanks a lot!

Pieter