You are not logged in.

leol

Beginner

  • "leol" is male
  • "leol" started this thread

Posts: 16

Location: Mexico City

  • Send private message

1

Thursday, December 8th 2005, 10:29pm

No matching function

Hi all:

I am reading QT Assistan examples, and i am trying to create my for based on designer/Calculator Form example. I have found 2 problems, first i read that if you use in the SOURCES a declaration like this

Source code

1
#include "ui_frmspin.h"


qmake generates automaticaly this file. I use this nomenclature, but i can't generate it automaticaly, instead i do a

Source code

1
uic frmspin.ui -o ui_frmspin.h


This solved the first problem, but when i tried to complie all the sources i reveived this error.

src\frmspin.cpp: In constructor 'frmspin::frmspin(QWidget*':
src\frmspin.cpp:8 error: no matching function for call to 'Ui::frmspin::setupUi(frmspin* const)'
inlcude/ui_fr,spin.h:38: note: candidates are: void Ui_frmspin::setupUi(QMainWindow*)

You guys can help me with this, i'm stucked!!!

Here are my code

frmspin.h

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef FRMSPIN_H
 #define FRMSPIN_H
 
 #include "ui_frmspin.h"
 
 class frmspin : public QWidget
 {
	Q_OBJECT
	
	public:
		frmspin(QWidget *parent = 0);
		
	private slots:
		void on_sb_input_a_valueChanged(int value);
		void on_sb_input_b_valueChanged(int value);
		
	private:
		Ui::frmspin gui;
 };
 
 #endif


frmspin.cpp

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
include <QtGui>
 
 #include "include/frmspin.h"
 
 frmspin::frmspin(QWidget *parent)
	: QWidget(parent)
{
	gui.setupUi(this);
}

void frmspin::on_sb_input_a_valueChanged(int value)
{
	gui.lblResult->setText(QString::number(value + gui.sb_input_b->value()));
}

void frmspin::on_sb_input_b_valueChanged(int value)
{
	gui.lblResult->setText(QString::number(value + gui.sb_input_a->value()));
}


main.cpp

Source code

1
2
3
4
5
6
7
8
9
10
 #include <QApplication>
 #include "include\frmspin.h"
 
 int main(int argc, char *argv[])
 {
	QApplication app(argc, argv);
	frmspin *spin = new frmspin;
	spin->show();
	return app.exec();
 }


des3.pro

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
######################################################################
# Automatically generated by qmake (2.00a) Thu Dec 8 14:27:37 2005
######################################################################

TEMPLATE = app
TARGET += 
DEPENDPATH += . include src
INCLUDEPATH += .

# Input
HEADERS += include/frmspin.h
FORMS += src/frmspin.ui
SOURCES += src/main.cpp src/frmspin.cpp

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

2

Thursday, December 8th 2005, 10:59pm

RE: No matching function

Quoted

Originally posted by leol
src\frmspin.cpp: In constructor 'frmspin::frmspin(QWidget*':
src\frmspin.cpp:8 error: no matching function for call to 'Ui::frmspin::setupUi(frmspin* const)'
inlcude/ui_fr,spin.h:38: note: candidates are: void Ui_frmspin::setupUi(QMainWindow*)

Looks like you have created an .ui file with layout not for a plain widget, but a main window.

Try this:

Source code

1
2
3
4
5
6
7
8
class frmspin : public QMainWindow
 {
	Q_OBJECT
...
frmspin::frmspin(QWidget *parent)
	: QMainWindow(parent)
{
...

leol

Beginner

  • "leol" is male
  • "leol" started this thread

Posts: 16

Location: Mexico City

  • Send private message

3

Thursday, December 8th 2005, 11:08pm

Yeap!!

You are correct!!
Thats my problem a layout generated in Designer.
Thank you very much!!

Regards,

leol

Beginner

  • "leol" is male
  • "leol" started this thread

Posts: 16

Location: Mexico City

  • Send private message

4

Friday, December 9th 2005, 3:31pm

Well, i have solved compilation problem, but i'm still trying to generate ui_frmspin.h when i run make, but it doesn't seems to work, i'm using QT 4.0.1, Open Source for windows, did i need to recompile qmake in order to add functionality??? ?(

Thanks for all your valuable help.

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

5

Friday, December 9th 2005, 3:39pm

Quoted

Originally posted by leol
Well, i have solved compilation problem, but i'm still trying to generate ui_frmspin.h when i run make, but it doesn't seems to work

Probably qmake haven't noticed that you use ui_frmspin.h and decided not to generate it.

Maybe something like this will help (in frmspin.h):

Source code

1
#include "include/ui_frmspin.h"
or

Source code

1
2
INCLUDEPATH += . include
UI_DIR = include

leol

Beginner

  • "leol" is male
  • "leol" started this thread

Posts: 16

Location: Mexico City

  • Send private message

6

Friday, December 9th 2005, 4:09pm

I have addit, the same include/ui_frmspin.h: No such file or directory

The only way i can create it is manually.

How does this works? ?(

Thanks,

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

7

Friday, December 9th 2005, 4:32pm

Quoted

Originally posted by leol
How does this works?

It works for me, but I keep headers in the same directory as sources.

leol

Beginner

  • "leol" is male
  • "leol" started this thread

Posts: 16

Location: Mexico City

  • Send private message

8

Monday, December 19th 2005, 10:56pm

Well i tried this using headers and sources in the same file,but this feature doesn´t seems to work, any one with the same problem?.

Do you recomend me to recreate the qmake file??

Thanks in advance.

LL

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

9

Monday, December 19th 2005, 11:06pm

Could you show us your project file?

leol

Beginner

  • "leol" is male
  • "leol" started this thread

Posts: 16

Location: Mexico City

  • Send private message

10

Monday, December 19th 2005, 11:17pm

Sure, here it is

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
######################################################################
# Automatically generated by qmake (2.00a) Fri Dec 9 11:03:58 2005
######################################################################

TEMPLATE = app
TARGET += 
DEPENDPATH += .
INCLUDEPATH += .

# Input
HEADERS += frmspin.h
FORMS += frmspin.ui
SOURCES += main.cpp frmspin.cpp


Regards

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

11

Tuesday, December 20th 2005, 10:22am

Try changing

Source code

1
2
DEPENDPATH += .
INCLUDEPATH += .
to

Source code

1
2
DEPENDPATH += . include
INCLUDEPATH += . include


Is include a subdirectory to the directory the project file resides in or is it its sibling? Where does your ui file reside?

leol

Beginner

  • "leol" is male
  • "leol" started this thread

Posts: 16

Location: Mexico City

  • Send private message

12

Tuesday, December 20th 2005, 5:31pm

That was my first attempt, so at this time all my files are in the same directory (Sources , headers and .ui file).

I had already tried moving different files to subdirectories but i dont find a way that qmake & make generate automatically the ui_form.h file.

Any advice?

Thank you,
LL

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

13

Tuesday, December 20th 2005, 7:41pm

Could you paste the message errors you get during compilation?

leol

Beginner

  • "leol" is male
  • "leol" started this thread

Posts: 16

Location: Mexico City

  • Send private message

14

Wednesday, December 21st 2005, 12:30am

Yes the message is that ui_frmspin.h not exist

Source code

1
2
In file included from main.cpp:2:
frmspin.h:4:25: ui_frmspin.h: No such file or directory


So if you go to the directory the ui_frmspin.h dont exist.

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

15

Wednesday, December 21st 2005, 9:37am

Could you attach your whole project here?

leol

Beginner

  • "leol" is male
  • "leol" started this thread

Posts: 16

Location: Mexico City

  • Send private message

16

Wednesday, December 21st 2005, 4:04pm

Here are all the files.

Thanks for all the help
leol has attached the following file:
  • des3a.tar.gz (27.67 kB - 72 times downloaded - latest: Jan 23rd 2011, 7:19pm)

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

17

Wednesday, December 21st 2005, 4:10pm

It compiles without any problems on my system (PLD Linux, Qt 4.1.0).

leol

Beginner

  • "leol" is male
  • "leol" started this thread

Posts: 16

Location: Mexico City

  • Send private message

18

Wednesday, December 21st 2005, 5:33pm

I don't know what's happening with mine, i tested in Fedora Core 4, QT 4.0.1 and it works fine, on Slackware 10.0 QT 4.0.1 don't work and in Windows XP, Qt 4.0.1 dont work also.

Well thank you for all the help, i will try compilng again qmake, if it doesn't work i generate header file manually.

Regards,
LL

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

19

Wednesday, December 21st 2005, 6:20pm

It is rather not a problem with qmake itself. More probably with your system (time wrong set?).