resetMoves() is a SLOT of myMainForm; I put myw to says this; but connect SEARCH it in MainForm....in mainForm there isn't! It's in myMainForm....
resetMoves() is a SLOT of myMainForm; I put myw to says this; but connect SEARCH it in MainForm....in mainForm there isn't! It's in myMainForm....
Regards
Hi, now I've tried this:
The Errors are these:Qt Code:
//constructor of myidget: myPopupmenu->insertItem("WireFrame", this, SLOT(setWireframe(true)), 4);To copy to clipboard, switch view to plain text mode
I don't understand: setWireframe(bool) there is and it's a slot; sender name unamed!?Qt Code:
To copy to clipboard, switch view to plain text mode
Any hints?
Regards
Yes, but you try to connect to "setWireframe(true)". You should already know that parameter names and values are forbidden inside SLOT and SIGNAL macros.Originally Posted by mickey
Is 'true' the problem? I change so and get still errors;
I'd like, when I selected item that setWirframe is called with parameter 'true'......
Qt Code:
myPopupmenu->insertItem("WireFrame", this, SLOT(setWireframe(bool)), 4);To copy to clipboard, switch view to plain text modeIn any way I don't understand this error...Qt Code:
QSignal::signal(const QVariant&) --> MyWidget::setWireframe(bool)To copy to clipboard, switch view to plain text mode
Regards
You can't connect a signal with QVariant parameter to a slot with bool parameter. Both types must be the same.Originally Posted by mickey
Hi! then I tried so and is ok;
Otherwise I thinked to insert a SLOT in myPopupmenu that should calls myWidget1->wireFrame(true). but how call setWireframe from a SLOT of myPopupmenu? (myWidget1 is member of myMainForm class) Thanks.Qt Code:
myPopupmenu->insertItem("WireFrame", this, SLOT(wire()), 4); void MyWidget::wire() { printf("hi\n"); this->setWireframe(true); }To copy to clipboard, switch view to plain text mode
Regards
You would have to subclass QPopupMenu, but your current solution is OK.Originally Posted by mickey
sorry I am still here....I've already subclassed QpopupMenu; my question was (a C++ question): how to call MyWidget instance (myWidget1) from a MyPopupmenu SLOT?
(myMainForm has myWidget1 instance)
Qt Code:
void MyPopupmenu::wireframe() { printf("hi\n"); myWidget1->setWireframe(true); // how to call? }To copy to clipboard, switch view to plain text mode
Regards
You must give a pointer to that widget to the MyPopupmenu instance. For example as one of the parameters of a constructor.Originally Posted by mickey
Since MyWidget is probably the parent of that menu you could use it:Qt Code:
// .h file class MyWidget; class MyPopupmenu : public QPopupMenu { Q_OBJECT public: MyPopupmenu( MyWidget *parent ); private slots: void wireframe(); private: MyWidget *_myWidget; }; // .cpp file: #include "MyWidget.h" MyPopupmenu( MyWidget *parent ) : QPopupMenu( parent ), _myWidget( parent ) { // ... } void wireframe() { if( _myWidget != 0 ) { _myWidget->setWireFrame( true ); } }To copy to clipboard, switch view to plain text mode
mickey (30th April 2006)
sorry,
but if can't call any SLOT with a parameter, I need to code many slot as the item in qpopmenu....I'm trying this....
Qt Code:
"WireFrame", this, SLOT(CALLpopupmenu()), 0, 0, 1); "Zoom in", this, SLOT(CALLpopupmenu()), 0, 1, 2); void MyWidget::CALLpopupmenu() { QPopupMenu* item = (QPopupMenu*)sender(); cout << " item " << item << endl; //item hasn't the true value }To copy to clipboard, switch view to plain text mode
Is thre a way to do this? (in this way or others) thanks in advance
Regards
You can invoke a slot with parameter, but its type must match the type of a corresponding signal parameter and you can't specify its value inside the SLOT macro.Originally Posted by mickey
What's wrong with that? What do you want to do in those slots? What signals will be connected to them?Originally Posted by mickey
I'd like that wireFrame SLOT starts when I choose an item from myPopupmenu; inserteItem members can only set the receiver...where can I set sender?? Is eg. the item 2, a possilble sender?Originally Posted by jacek
Nothing wrong; but so I have some SLOT that calls SLOT; I think is good find a why to use only a SLOT called from item in myPopupmenu (every item has an index or an id); and inside it calls the slots... but I don't know how..Originally Posted by jacek
Regards
Bookmarks