
Originally Posted by
dejvis
i want to have 2 QActions in menubar: first to enable treeview, second to enable columnview.
How to write connection betwen QAction and QStackedWidget to switch pages?
A direct connection is not possible. Just create two private slots and connect the correspondent action to it. The slot - normal member function - changes the page. (<- you have to do that.)
If you only want to use one slot look a QSignalMapper.
Edit:
// in your *.h
private slots:
void slotPage1();
// in your *.cpp
connect(action1, SIGNAL(triggered()), this, SLOT(slotPage1()));
//...
void MyClass::slotPage1()
{
stackedWidget->setCurrentIndex(0);
}
// in your *.h
private slots:
void slotPage1();
// in your *.cpp
connect(action1, SIGNAL(triggered()), this, SLOT(slotPage1()));
//...
void MyClass::slotPage1()
{
stackedWidget->setCurrentIndex(0);
}
To copy to clipboard, switch view to plain text mode
Bookmarks