TAILIEUCHUNG - KDE 2/Qt Programming Bible phần 3

Đóng gói vật dụng từ cuối cùng có tác dụng tương tự như đóng gói chúng từ đầu, ngoại trừ mỗi widget được đặt ở vị trí có sẵn tiếp theo bắt đầu từ phía dưới. Nút đầu tiên được thêm vào phía dưới là một trong những tạo ra trên đường dây 25 thông qua 27, và được thêm vào của các cuộc gọi đến packEnd () trên dòng 28. | Chapter 6 Menus and Toolbars 127 The method createStatusBar on line 36 calls statusBar to create and install a widget capable of displaying a single line of text. Your program has access to the text of the status bar so it can keep it constantly updated. Unlike the toolbar and the menu bar the status bar cannot be moved to another location. The method createToolBar on line 41 creates a toolbar by calling toolBar on line 43. An ID number is required as an argument because your application can have as many toolbars as you would like. You supply the ID number and if there is no toolbar with that ID one is created and returned. Using the same ID number will always return the same toolbar. For this example a pixmap is used to create a single toolbar button. The toolbar can be moved outside of its parent window. Figure 6-3 shows the result of using the handle at the left end of the toolbar to tear off the menu from its parent window and establish it as its own stand-alone window. Figure 6-3 Tear-off menus and toolbars The method named slotExit on line 47 is called whenever the user selects Exit from the menu. You may need to do some kind of cleanup here and save currently unsaved data but this example simply calls the exit method in the application. The global variable named kapp always contains a pointer to the KApplication object. The slot method named queryClose on line 51 is called when the figure X in the upper right corner of the application s frame is selected. If this slot returns TRUE the application is immediately closed. If it returns FALSE no action will be taken the signal from the X button will be ignored . This is the skeleton of an application. Allowing KTMainWindow to do most of the work your top-level window can be very sophisticated with only a few lines of code. The rest of this chapter describes the details of configuring the menu bar and toolbars and displaying information via the status bar. 128 Part I Getting Started The Menu Bar Basically a menu

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.