Disabling a QCheckbox in a tricky way

I want to make a QCheckBox named "Show Captions" disable another QCheckBox named "Show captions if no title" when the first is checked, but my problem is that how I can make it disabled immediately when the user checks the first checkbox.

SetupSlideShow::SetupSlideShow(QWidget* parent)
    : QScrollArea(parent), d(new SetupSlideShowPriv)
    QWidget* panel = new QWidget(viewport());

    QVBoxLayout* layout = new QVBoxLayout(panel);

    d->showComment = new QCheckBox(i18n("Show captions"), panel);
    d->showComment->setWhatsThis( i18n("Show the image caption at the bottom of the screen."));

    d->showTitle = new QGroupBox(i18n("Show title"), panel);
    d->showTitle->setWhatsThis( i18n("Show the image title at the bottom of the screen."));

    d->showCapIfNoTitle = new QCheckBox(i18n("Show captions if no title"), panel);
    d->showCapIfNoTitle->setWhatsThis( i18n("Show the image caption at the bottom of the screen if no titles existed."));
    QVBoxLayout *vbox = new QVBoxLayout;


Doesn't this work?

connect(d->showComment, SIGNAL(toggled(bool)), d->showCapIfNoTitle, SLOT(setDisabled(bool)));

The call to paintEvent() isn't really doing anything for you regarding immediacy. Nothing will be repainted until control returns to the event loop (after your constructor exits). It is more typical to call update() but even this is unnecessary when changing the properties of built in widgets.

To link the check boxes, define a slot for the stateChanged() signal of showComment, connect the signal to your slot in your constructor above (by calling connect(), and in that slot, call d->showCapIfNoTitle->setCheckState(d->showComment->checkState()).

Need Your Help

NEED help about Android application

android matlab

i am developing an application using optical character recognition (OCR) for android system Mobiles.

Relation between preprocessing and translation

c compiler-construction compilation translation

Do we have any relationship between preprocessing and translation process? and when does preprocesing occurs before or after translation process ?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.