QToolBar inherits QDockWindow, so i think you can use it instead QDockWindow![]()
QToolBar inherits QDockWindow, so i think you can use it instead QDockWindow![]()
a life without programming is like an empty bottle![]()
Do you mean I can use a QToolbar in a QDockWindow? I don't want to do that.Originally Posted by zlatko
Or Do you mean I can use QActions in a QDockWindow the same way as I can use them in QToolbar?
I mean that you must use QToolBar instead QDockWindow
a life without programming is like an empty bottle![]()
Use QToolButton objects.
I have tried that but I specifically want to use checkboxes. My menu consists of checkable items and I want my dock window to contain a list of checkable items also.Originally Posted by wysota
I notice that QWidget has an addAction() method. I thought that I could create a QCheckbox then call addAction() on it to syncronise it with the action, but that doesn't work. What's the point of QWidget::addAction()?
Well, docs say about this:Originally Posted by Paul Drummond
As I understand, it is just for example for simplifying constructing of context menus and so on. At least it is an easy way to pass a set of actions to a widget for later usage without needing to dangle them around as member variables or so..All QWidgets have a list of QActions, however they can be represented graphically in many different ways. The default use of the QAction list (as returned by actions()) is to create a context QMenu.
Basically you could try adding your checkboxes where ever you wish, and then connecting check boxes' toggled(bool) signals to according QAction::toggle(bool) slots. This could work as long as the check boxes are't tri-state (which wouldn't make sense either).
Last edited by jpn; 2nd March 2006 at 11:16.
Someone's a bit dulled..
Here's a tiny example of syncing QActions with QCheckboxes. All behaviour done with Designer.. All I did was connecting toggle(d) signals 'n slots between checkboxes and actions to both directions and voilá!
A checkbox is equal to a button with checkable property set to true.Originally Posted by Paul Drummond
Yeah, but it doesn't look the same does it!?!! I want a little white box that I can tick. When using a QToolbutton with the checked property set, it just sets the button to be "pressed".Originally Posted by wysota
Well... yes, that's how tool buttons usually behaveOriginally Posted by Paul Drummond
![]()
That's my point, I want CHECKBOXES!Originally Posted by wysota
I understand what QAction does. You define an action once then the menu item and toolbar button associated with the action are sync'd. It's just a shame QAction is limited to menus and toolbars that's all.
It's quite easy for me to do the synchronisation myself, I just didn't want to if QAction did it for me, but it obviously doesn't.
Thanks guys for helping to make this clear to me.
Hmm... when I think of "action" I belive this is something that I can trigger. With checkboxes I don't see how marking it as checked or not triggeres some action. Of course, an action can be checkable, but it still is (logically) associated with some action being taken. For me it would make more sense to associate an action with a QPushButton more than with QCheckBox. But we have QToolButton for thatAn action associates things like text, icon, tool tip, etc. not only a slot which will get run after activating the widget. Both QPushButton and QCheckBox (and QRadioButton too) are just not meant for actions. If you want, you can always subclass them and add a feature of associating an action with each of them. There is a changed() signal in QAction. I belive you can use it for that.
desch (27th November 2007)
What about checkable menu items then? They can be associated with actions. I can't see how QToolButton and QMenuItems are "special" in that they are the only widgets that can be syncronised with QAction. A Checkbox is a button just like a QToolButton so it should work with QAction IMO.
A checkbox can have 3 states..
Bookmarks