PDA

View Full Version : Menubars, toolsbars and docking controls



mridey
14th November 2006, 13:27
Hi,

My first app is quite simple. Basically if I could reproduce Notepad as a sample app, it would resolve most of my questions.
The questions are:

- How do I handle events from menu/toolbar entries once i've added them into the menubar/toolbar in the designer?
- How do I add icons to the menu items in the designer?
- How do I add icons in the toolbar items in the designer?
- Should I be doing menus and toolbars in code rather than using the designer?

- If I drop a textbox in the middle of the form, what properties do I set so that the widget always takes the whole available area as I resize the dialog?

- For a "Open" menu item, how to I launch the FileOpen dialog?
- For a "Save" menu item, how do I launch the FileSave dialog?

And a more complex question:

- How do I insert a QAxWidget into the form at runtime, instead of using the designer?
- And then, how to I access the methods of that associated control?

Thanks

wysota
14th November 2006, 17:35
- How do I handle events from menu/toolbar entries once i've added them into the menubar/toolbar in the designer?
Objects entered into menus and toolbars are QActions. You can use signal and slot connections and connect a slot (custom or builtin) to an triggered() signal of a particular QAction.


- How do I add icons to the menu items in the designer?
- How do I add icons in the toolbar items in the designer?
If you click on a menu entry, you'll get a list of its properties in the property browser. To add an icon, just change its icon property.

You can use the "action editor" to edit your actions easily and then just drag an action from the editor to a toolbar or menu.


- Should I be doing menus and toolbars in code rather than using the designer?
No, you can do that from designer easily.



- If I drop a textbox in the middle of the form, what properties do I set so that the widget always takes the whole available area as I resize the dialog?
Properties won't handle that. Read about layouts (http://doc.trolltech.com/4.2/layout.html) - you can add them from within Designer.


- For a "Open" menu item, how to I launch the FileOpen dialog?
- For a "Save" menu item, how do I launch the FileSave dialog?
Create a custom slot that will call a particular method from QFileDialog class and connect it to the triggered() signal of the action.


And a more complex question:

- How do I insert a QAxWidget into the form at runtime, instead of using the designer?
- And then, how to I access the methods of that associated control?


Indeed a more complex question. I suggest you read QAxWidget docs and take a look at examples that describe how to use it.

elcuco
15th November 2006, 22:32
MyWindow::on_actionSave_triggered()
{
/// blah
}


Read on the documentation about "Automatic Connections" in the designer part (under Using Forms and Components).