Results 1 to 3 of 3

Thread: Menubars, toolsbars and docking controls

  1. #1
    Join Date
    Nov 2006
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Menubars, toolsbars and docking controls

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Menubars, toolsbars and docking controls

    Quote Originally Posted by mridey View Post
    - 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 - 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.

  3. #3
    Join Date
    Jan 2006
    Posts
    369
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Menubars, toolsbars and docking controls

    Qt Code:
    1. MyWindow::on_actionSave_triggered()
    2. {
    3. /// blah
    4. }
    To copy to clipboard, switch view to plain text mode 

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.