Qt Pb with QAction, QToolBar, QToolButton



  • Hello guys,

    I got a problem here.

    I'm building a Qt app that uses slidingStackedWidgets in order to slide from one page to another one.

    I have 2 toolBars, a topToolBar and a bottomToolBar that do not slide when the central widget moves.

    So I have declared a QAction in my mainWindow.h

    @ QAction *backToMainVert;@

    And in my mainWindow.cpp, when I call the second view by clicking a button, I call a slideInAdd() method that goes like this:
    @
    slidingStacked->slideInIdx(1); //this takes me back to my second page
    backToMainVert = this->topToolBar->addWidget(backBarButton);
    //this adds a backButton to the topToolBar@

    Now the backBarButton is connected to a slideToMain() method which, when triggered takes me back to my first page and removes the backBarButton from the topToolBar

    @ this->topToolBar->removeAction(backToMainVert);
    slidingStacked->slideInIdx(0);@

    The first time I switch to the second page, no problem, my button is created and displayed on my topToolBar.

    When I click the backBarButton, it goes back to the first page.

    BUT the second time I want to return from the first page to the second page, the backBarButton never appears.

    Uh, maybe this can help, here is the way I instantiate my backBarButton :

    @backBarButton = new QToolButton(this);
    backBarButton->setText("Retour");
    backBarButton->setFixedSize(80,30);
    backBarButton->setStyleSheet("background-image: url(:/ToolBarButton.png);"
    "background-repeat: no-repeat;"
    "background-position: center center;"
    "border:0;"
    "color : white;"
    "font-family: System;"
    "font-style: bold;"
    "font-size: 9pt;"
    "color : white;");@

    Any idea what I'm missing here please ?

    Thanks in advance, I'm stuck.

    Miky Mike



  • Hi Mike,

    there is code missing to have more knowledge on your problem:

    how do you slide back and what do you do in that code (esp. with the back button)

    I'm not sure, what removeAction does exactly (with the action and the button)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.