PDA

View Full Version : how to delete a QToolButton inQt



Soumya Somasekhar Ram
6th September 2013, 08:45
I want to delete A toolbutton,which is created dynamically.
So first wwe want to identify which toolbutton is active and then delete it.
The following code can't identify the active tool button and even delete it.
here unselectedButtinMap[instance] displays the lastcreated button. but the sender function gives the windows id.
So they wont match and can't delete the QToolButton.
foreach(QString instance, unselectButtonMap.keys())
{
if(unselectButtonMap[instance] == QObject::sender())
{
QMessageBox::warning(0,tr("Warning"),tr("do you want to delete the folder"));
unselectButtonMap[instance]->hide;
}}
Can any one suggest any other method?
Also suggest a method to delete the QToolButton.

Thanks in advance

wysota
6th September 2013, 09:40
The sender() function returns a pointer to the object that emitted the signal, not any "windows id".

Soumya Somasekhar Ram
6th September 2013, 11:40
How will I get the current object reference?

wysota
6th September 2013, 13:59
What do you consider a "current object"?

Soumya Somasekhar Ram
10th September 2013, 07:34
Which object the user clicks is reffered to as current object.

wagmare
10th September 2013, 08:08
Which object the user clicks is reffered to as current object.

may this can help u ..
http://qt-project.org/doc/qt-4.8/qapplication.html#focusWidget

use
qApp->focusWidget();
the widget u can remove using delete.

wysota
10th September 2013, 08:17
Which object the user clicks is reffered to as current object.

Very weird.... Are you sure you shouldn't be using GraphicsView?

Soumya Somasekhar Ram
23rd September 2013, 13:45
I want to maintain a gridlayout.While adding buttons,it should be in the row by column manner and when we delete any item, the remaining items should be rearranged to maintain the currect layout.
can u suggest any method to neatly arrange the buttons.
Thanks in advance.