Hello, don't meant to bug anybody again, =/. QDockWidget not doing what I expected it to do.
-
Hello, I was trying to get my QDockWidget WIdget to hide and show when a user clicks the Checkbox, but it didn't appear to be doing what I expected it to do.
I have included a link to my sources. Whoops, forgot to add more, it does compile, but it appears to be showing and not hiding.
-
In your constructor you use :
@ if (showdckWidgetChkBox->isChecked()) {
showdckWidgetChkBox->show();
} else {
showdckWidgetChkBox->hide();
}@This means that only once the hide or show will work.
On the same place you should use a connect :
Use the checkbox as sender and the dockwidget uses a slot to act on that. -
example code
@connect(ui->checkBox, SIGNAL(toggled(bool)), ui->dockWidget, SLOT(setHidden(bool)));@of course you should adapt the widget names to your needs.
-
[quote author="Eddy" date="1310895955"]example code
@connect(ui->checkBox, SIGNAL(toggled(bool)), ui->dockWidget, SLOT(setHidden(bool)));@of course you should adapt the widget names to your needs.[/quote]
Okay, thanks, that worked, but another bug, =/. But when it is checked, it's hidden, =/.
-
@
connect(ui->checkBox, SIGNAL(toggled(bool)), ui->dockWidget, SLOT(setVisible(bool)));
@ -
[quote author="loladiro" date="1310898744"]@
connect(ui->checkBox, SIGNAL(toggled(bool)), ui->dockWidget, SLOT(setVisible(bool)));
@[/quote]Heh, awesome, thanks for the help, that worked, sorry, I should have known this, as much as I've been studying Qt, you'd think, by now, after 3 or more months, I know it all, hahaha.. Honestly, I don't, it's due to my laziness and not doing anything other than Menus and QTextEdits, decided to try something different for a change, and so far, heck yeah, =). Thanks again.
-
if you want to learn about signals and slots :
"this is a must have read :":http://doc.qt.nokia.com/4.7/signalsandslots.html
-
[quote author="Eddy" date="1310900176"]if you want to learn about signals and slots :
"this is a must have read :":http://doc.qt.nokia.com/4.7/signalsandslots.html[/quote]
Looks to me like almost all things in Qt requires Sigs/Slots..
-
Hi Richard,
not all but it is very usefull and ion many places needed :-)
Especially for UI inetraction or for asynchronous things. -
[quote author="Gerolf" date="1310903850"]Hi Richard,
not all but it is very usefull and ion many places needed :-)
Especially for UI inetraction or for asynchronous things.[/quote]Heh, have to write more codes it appears, when a user clicks the X, the Checkbox doesn't automatically Uncheck. Also, having an issue with getting the DockWidget to stay small, I did get it so it stays at bottom, but now it's onto learning how to make it resize, tried the dckwidget->setGeometry(0, 150, 1024, 100); but it didn't appear to do anything, =/. It still stays just as large as the parent window.
-
You need to emit a signal from the dockwidget and connect it with a slot of the checkbox.
-
[quote author="Eddy" date="1310905367"]You need to emit a signal from the dockwidget and connect it with a slot of the checkbox.[/quote]
Argh, too sleepy to understand now, ahahaha.. That just went over my head, later I'll get to it, LOL..
-
It's not that difficult.
Hint : Use the same approach as before. Look for a signal and slot with a bool argument.