QStackedWidget setCurrentIndex slot not showing on Signals&Slots editor (QtCreator)
-
hi
the
void setCurrentIndex(int index)
wants an int to tell which page to show.
The button clicked() or released() signal does not have
int as a parameter so you cannot hook that signal to that slot as there
is no way the button can send the index.However, the button can call a normal slot in main and
there you can call setCurrentIndex with a index. -
@cxam
just to be sure, u did see
http://doc.qt.io/qt-5/qwizard.html
which is for wizard type of interface. -
@mrjj said:
I said Setup Wizard as an example, what I exactly want is a main menu from where you can go to different interfaces, so I need buttons to go through pages. (This app is going to be running on a Raspberry Pi 2 using EGLFS)
-
ok
QStackedWidget seems right for a multipage application. -
@mrjj More or less like this:
void MainWindow::on_Cambio1_clicked() { int cambio1; cambio1 = 0; void QStackedWidget::setCurrentIndex(cambio1); }
I don't know why but it comes up with this error:
error: invalid use of qualified-name 'QStackedWidget::setCurrentIndex' int QStackedWidget::setCurrentIndex(cambio1); ^
-
@cxam
well i would expect something like
void MainWindow::on_Cambio1_clicked()
{
// int cambio1; <<< move to mainwinow.h in the class so all buttons have access to this "current-page"
cambio1++; // take next page//
ui->YourQStackedWidget->setCurrentIndex(cambio1);
}
set cambio1= 0 in mainwin constructorA more clean way might be to use to functions
nextPage() and prevPage() in mainwindow
and the buttons just call that and it does the page switch back and forth.please try this sample
https://www.dropbox.com/s/hpjtrr1xvo3lakw/stackedinteface.zip?dl=0 -
The error comes from the fact that your are trying to call a class method like it's a static method.
Even if you don't use QWizard, you can take a look at its implementation to get started.