Qt World Summit: Submit your Presentation

[SOLVED] hide multiple buttons with slot

  • Hiho,
    as the title says I'm trying to hide multiple buttons with a slot.
    The action is called with every change of a treeview (this works)
    but the problem is that the buttons won't be hidden.
    Here is what I have for now:

    This is the connection for a treeview in the ui_main.h
    @QObject::connect(treeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), MainWindow, SLOT(slot_selectionChanged(const QModelIndex &, const QModelIndex &)));@
    And in the MainApplicationWindow.h:
    @void slot_selectionChanged(const QModelIndex & index1, const QModelIndex & index2){
    /reads some data from the treeview/
    ui->changePalette(value); //hides all buttons and shows the needed ones again
    and here again in my ui_main.h the function which should hide the buttons

    @void changePalette(std::string value){
    //and so on

        if(!strcmp(value.c_str(), "ground")){
                pushButton->setStyleSheet(QString::fromUtf8("background-image: url(../media/terrain/map/textures/grass.gif);"));
                pushButton_2->setStyleSheet(QString::fromUtf8("background-image: url(../media/terrain/map/textures/sand.gif);"));
        else if...@

    The strange thing is that I can hide the frame the buttons are in, but not the buttons themself
    I hope somebody can help me :)
    Thanks in advance and best regards

  • Ok well I just solved the problem :)
    I didn't set a backgroundcolor / image for the frame the buttons were in.
    Now it works as it should

Log in to reply