PDA

View Full Version : Tool bar as photoshop, where only one is selected.



ricardo
23rd June 2009, 11:52
Hi friends!

Is there any easy way to create a tool bar with checkeable actions where only one action may be selected at once?
I'm trying to use toggled signals, but my code looks ugly and difficult.

Any suggestion/idea?

Thanks in advance.

Lykurg
23rd June 2009, 12:02
Simply use setAutoExclusive().

ricardo
23rd June 2009, 14:42
Simply use setAutoExclusive().

Yes, you are right, after reading the docs, it seems that is what I'm looking for.
Just one question, can I use Designer or must I do that by code?

Thanks.

Lykurg
23rd June 2009, 14:56
can I use Designer
Yes, of course, look at the property editor!

ricardo
23rd June 2009, 15:39
Perhaps you are wrong about Qt Designer. I've been looking for setAutoExclusive on QAtions and QToolBar but there is nothing at property editor.

I guess I have to create by code a QActionGropu and add actions, and after that, add it to a tool bar (no idea how to)

Another question is: Why this code does not delete/destroy alignmentGroup variable?
http://doc.trolltech.com/4.1/mainwindows-menus-mainwindow-cpp.html

What do you think Lykurg? By the way, thanks a lot, you are very helpful.

Lykurg
23rd June 2009, 15:56
Perhaps you are wrong about Qt Designer. I've been looking for setAutoExclusive on QAtions and QToolBar but there is nothing at property editor.
I guess I have to create by code a QActionGropu and add actions, and after that, add it to a tool bar (no idea how to)


Ah, ok, I was wrong. It is only displayed as an action not as the tool button, which it is in fact. So you have it to do in your code. But simply create a QToolButton, add the action, set autoExclusive and add the button to the toolbar. should work without a action group (when you don't have other "normal" actions inside the toolbar), it does at least work inside a QFrame.



Another question is: Why this code does not delete/destroy alignmentGroup variable?
http://doc.trolltech.com/4.1/mainwindows-menus-mainwindow-cpp.html
Because the parent deletes it by itself, if it gets destroyed.

ricardo
23rd June 2009, 16:09
Thaks, useful.