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. Delete widgets when a button is clicked
Forum Updated to NodeBB v4.3 + New Features

Delete widgets when a button is clicked

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.2k 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.
  • F Offline
    F Offline
    fouffa89
    wrote on last edited by
    #1

    When add button is clicked a Progresss bar and a delete button are added to a scollarea in a new line and when delete button is clicked the whole line (progress bar and delete button) must be deleted .
    @
    int nb=1;
    void on_AddButton_clicked()
    {
    //add progress bar in a new line
    QProgressBar *progress=new QProgressBar(this);
    progress->setObjectName("p"+QString::number(nb));
    //add delete ToolButton
    QToolButton *bt=new QToolButton(this);
    bt->setObjectName("bt"+QString::number(nb));
    bt->setIcon(QIcon(":/new/images/images/cancel.png"));
    bt->setIconSize(QSize(40,40));
    bt->setAutoRaise(true);
    //connect delete button to the slot deleteLine to delete the scrollbar and the delete button
    connect(bt,SIGNAL(clicked()),this,SLOT(deleteLine()));

    grid->addWidget(progress,nb,1);
    grid->addWidget(bt,nb,2);
    ui->scroll->setLayout(grid);
    nb++;
    

    }
    @

    The problem is that I don't know the number of the line where the delete button is clicked and i have a problem with the slot deleteLine it doesn't seem to work.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I can see two approaches. First, get familiar with QSignalMapper.

      Alternatively, make your whole row a single widget, and make it handle its own destruction.

      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