You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, May 10th 2012, 8:42pm

button signal/slot

Hi,
to change the position of my cam when inter x,y,z
i make that

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
Coordinate3dWidget::Coordinate3dWidget(QWidget *parent):
    QWidget(parent)
{
pos_cam = new QGroupBox(this);
sbx_cam = new QDoubleSpinBox(pos_cam);
lx_cam = new QLabel(pos_cam);
sby_cam = new QDoubleSpinBox(pos_cam);
ly_cam = new QLabel(pos_cam);
sbz_cam = new QDoubleSpinBox(pos_cam);
lz_cam = new QLabel(pos_cam);
connect(sbx_cam, SIGNAL(valueChanged(double)), this, SLOT(onCoordinateChanged()));
	         connect(sby_cam, SIGNAL(valueChanged(double)), this, SLOT(onCoordinateChanged()));
	         connect(sbz_cam, SIGNAL(valueChanged(double)), this, SLOT(onCoordinateChanged()));

and

Source code

1
2
3
4
5
page_14= new Coordinate3dWidget;
connect(page_14, SIGNAL(coordinateChanged(const Ogre::Vector3&)),
            ogreWidget, SLOT(setCameraPosition(const Ogre::Vector3&)));
    connect(ogreWidget, SIGNAL(cameraPositionChanged(const Ogre::Vector3&)),
            page_14, SLOT(setNewCoordinate(const Ogre::Vector3&)));

that work very good

when i want change and make when i enter x,y,z and clic to button it change the positon of the cam it dos not work
i make like that

Source code

1
2
3
4
5
6
repo_cam = new QToolButton(page_14);
connect(repo_cam,SIGNAL(clicked()),ogreWidget,SLOT(setCameraPosition(const Ogre::Vector3&)));
connect(page_14, SIGNAL(coordinateChanged(const Ogre::Vector3&)),
            ogreWidget, SLOT(setCameraPosition(const Ogre::Vector3&)));
    connect(ogreWidget, SIGNAL(cameraPositionChanged(const Ogre::Vector3&)),
            page_14, SLOT(setNewCoordinate(const Ogre::Vector3&)));

it dos not work

2

Thursday, May 10th 2012, 11:16pm

connect(repo_cam,SIGNAL(clicked()),ogreWidget,SLOT(setCameraPosition(const Ogre::Vector3&)));

you cant connect signals to slots with more arguments

clicked() - zero arguments
setCameraPosition(const Ogre::Vector3&) - one argument.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

3

Thursday, May 10th 2012, 11:26pm

Quoted

you cant connect signals to slots with more arguments

what you mean?
can you more explain to me please?

4

Friday, May 11th 2012, 8:48am

clicked() - zero arguments
setCameraPosition(const Ogre::Vector3&) - one argument
=> not allowed. How is clicked() signal meant to make up a value for Vector3d? Guess it?

signal(int, char) - two arguments
slot(int) - one argument
This signal can be connected to the slot because the signal has more arguments.

signal(int) - twoone arguments
slot(int, char) - onetwo argument
This signal cannot be connected to the slot because the signal has fewer arguments.


what's not to understand?

edit:
copy/paste error
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

This post has been edited 1 times, last edit by "Amleto" (May 11th 2012, 11:56am)


5

Friday, May 11th 2012, 10:38pm

Quoted

clicked() - zero arguments
setCameraPosition(const Ogre::Vector3&) - one argument
=> not allowed. How is clicked() signal meant to make up a value for Vector3d? Guess it?

change and i make like that

Source code

1
connect(repo_cam,SIGNAL(clicked()),page_14,SLOT(add()));

aand in the slot add

Source code

1
2
3
4
5
6
7
void MainWindow::add()
{
   connect(page_14, SIGNAL(coordinateChanged(const Ogre::Vector3&)),
            ogreWidget, SLOT(setCameraPosition(const Ogre::Vector3&)));
    connect(ogreWidget, SIGNAL(cameraPositionChanged(const Ogre::Vector3&)),
            page_14, SLOT(setNewCoordinate(const Ogre::Vector3&)));
}

it dos not make to me error
but he do not change the pos of the cam when i clic but it change when i enter the new pos

6

Friday, May 11th 2012, 11:06pm

fyi: "does", not "dos".

Why are you connecting signals in add() ?? signal connection should be done in constructor. What you have done means that every time you click add, the signals get connected AGAIN. This means SLOT(setCameraPosition(const Ogre::Vector3&) will be called MULTIPLE times for each SIGNAL(coordinateChanged(const Ogre::Vector3&)

Please think about what you are doing - how is any program meant to guess where to add a camera if you dont give enough information? It can ONLY put a camera in a position when you have TOLD it the position.

I implore you to please lean Qt basics. In fact I'm going to give up on this thread. You should learn to walk before you run. You continuing on this path is going to lead to a new question every thirty seconds because something else is wrong - just because you dont understand what you are doing.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.