[Qt-interest] Hiding rows and columns of buttons in a grid layout - segfault
Camilo Polymeris
cpolymeris at gmail.com
Sun Sep 19 03:47:10 CEST 2010
Hello
I am writing this application: emutrix.googlecode.com
Trying to hide columns of push buttons depending on the radiobuttons
the user checks, the application SEGFAULTs. The pushbuttons are
organized in columns as QButtonGroups of 35 or so buttons.
What is strange is that it doesn't always crash and I haven't been
able to reconstruct when. Is it possible that a QButtonGroup gets
destroyed on some event, like when all its buttons are hidden?
At the end of this post is the relevant code. Any ideas how to fix
this or better ways to implement visibility toggling for a large group
of buttons is appreciated. Maybe handling the QGridLayout that
contains all buttons?
BTW, I want to hide certain rows too, but haven't yet started to
implemented the code. See this screenshot to get an idea:
http://code.google.com/p/emutrix/#Screenshot
Thanks,
Camilo
void MainWindow::on_con0202_toggled(bool checked)
{
QList<QButtonGroup*> cols =
this->findChildren<QButtonGroup*>(QRegExp("b0[r,l]"));
for (QList<QButtonGroup*>::iterator it = cols.begin();
it != cols.end(); ++it)
setButtonGroupVisible(*it, checked);
}
void MainWindow::setButtonGroupVisible(const QButtonGroup * bg, bool visible)
{
assert(bg);
for (QList<QAbstractButton *>::iterator it = bg->buttons().begin();
it != bg->buttons().end(); ++it)
(*it)->setVisible(visible);
}
More information about the Qt-interest-old
mailing list