Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] hide multiple buttons with slot
Qt 6.11 is out! See what's new in the release blog

[SOLVED] hide multiple buttons with slot

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ritschratsch
    wrote on last edited by
    #1

    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){
    pushButton->hide();
    pushButton_2->hide();
    pushButton_3->hide();
    //and so on

        if(!strcmp(value.c_str(), "ground")){
                pushButton->setStyleSheet(QString::fromUtf8("background-image: url(../media/terrain/map/textures/grass.gif);"));
                pushButton->show();
                pushButton_2->setStyleSheet(QString::fromUtf8("background-image: url(../media/terrain/map/textures/sand.gif);"));
                pushButton_2->show();
        }
        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
    Ritti

    1 Reply Last reply
    0
    • R Offline
      R Offline
      ritschratsch
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved