Connect to...without slots...
I have code:
Code:
int main(int argv, char * argc[])
{
window
->setGeometry
(QRect(200,
200,
300,
300));
window->setWindowTitle("QFileDialog example");
window->setMaximumSize(300,300);
window->setMinimumSize(300,300);
newFile
->setGeometry
(QRect(50,
25,
250,
35));
saveFile
->setGeometry
(QRect(50,
75,
250,
35));
layout->addWidget(newFile,0,0,1,1,Qt::AlignHCenter);
layout->addWidget(saveFile,1,0,1,1,Qt::AlignHCenter);
window->connect(...); // ?
window->setLayout(layout);
window->show();
I need to connect button with function ( I don't have class )
something like:
Code:
window->connect(newFile,SIGNAL(cliecked()),newFile,SLOT( myImaginedFunc()));
doesn't work because it calls:
which doesn't exist.
Re: Connect to...without slots...
You could try to write a new function which would be located underneeth (or above) your main() function.
your connect statement would be something like:
Code:
window->connect(newFile,SIGNAL(clicked()),this,SLOT( myImaginedFunc()));
I can imagine that you would have to define 'myImaginedFunc()' as a slot somewhere. I don't know if this can be done in your .cpp file. You might want to create a .h file to do this in.
If this doesn't work, it might be easier to just create a class from which you create your window. The slot can be defined in this class.
Good luck.
Re: Connect to...without slots...
I think you can create an auxiliary class which will have your function and yhis function will be declared as a slot. In this case your connect statement will be valid.
But in general, I think this is not a normal situation and i think you need to review your application's design.