0

I have a start/stop button which i want to control which tab is being shown in the tabWidget.

here's how I'm doing it.

// Control START/STOP actions
void gui::start_stop()
{
    if (acquisition == 0)
    {
        acquisition = 1;
        ui->pushButton->setText("STOP \nACQUISITION");
        ui->pushButton->setStyleSheet("background-color: #8090d0; border-radius: 5px; color : #ffffff;");
        ui->tab_acquisition->raise();

    }

    else
    {
        acquisition = 0;
        ui->pushButton->setText("START \nACQUISITION");
        ui->pushButton->setStyleSheet("background-color: #6673a6; border-radius: 5px; color : #ffffff;");
        ui->tab_settings->raise();

    }
}

the problem is that the tab_acquisition and tab_settings don't get raised

thanks

SamuelNLP
  • 4,038
  • 9
  • 59
  • 102

1 Answers1

1

You are supposed to tell us if you have issues with this method, if you try to connect it to the clicked signal make sure it's declared with slots access specifier.

Zlatomir
  • 6,964
  • 3
  • 26
  • 32
  • sorry, the problem is that the tab_acquisition and tab_settings don't get raised – SamuelNLP Jan 31 '13 at 17:39
  • Have you tried calling [setCurrentWidget](http://doc.qt.digia.com/qt/qtabwidget.html#setCurrentWidget) with the pointer to a widget that is added to your tabWidget? LE: instead of calling _raise()_ – Zlatomir Jan 31 '13 at 17:45
  • 2
    tabWidget->setCurrentWidget(ui->tab_acquisition); is not working? Is tabWidget a [QTabWidget](http://doc.qt.digia.com/qt/qtabwidget.html), or what type? If it's QTabWidget are those two widgets added as tabs into tabWidget? – Zlatomir Jan 31 '13 at 17:50
  • 3
    Zlatomir's suggestion of QTabWidget::setCurrentWidget should have the desired functionality. I use it all the time. – Phlucious Jan 31 '13 at 18:06
  • 1
    just a small correction, the code most likely should be preceded by _ui->_ so: _ui->tabWidget->setCurrentWidget(ui->tab_acquisition);_ – Zlatomir Jan 31 '13 at 18:07