Rapid GUI Development with QtRuby phần 3

Tham khảo tài liệu 'rapid gui development with qtruby phần 3', ngoại ngữ, ngữ pháp tiếng anh phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 4 Get Your Feet Wet Instead of going through the routine of trying to learn the arcane details of QtRuby before using it let s jump straight into an example. Your first program Fire up your favorite text editor and type in this program o require Qt app Qt ARGV label Qt Hello World nil 0 150 30 label Then try executing it. ruby If all went well your program should popup something like Figure . Figure Hello World Example BOOKLEET Chapter 4. Get Your Feet Wet Your first program 20 By using the setCaption method on your main widget you can change the text that appears in the window title bar of your application. Let s take a closer line-by-line look. o First we load the QtRuby library. We typically pass Ruby s ARGV array of command line arguments to the Qt Application initializer because QtRuby applications have built in support for command line switches that can alter the behavior of the program. Next we create a Qt Application object. Qt Application is the foundation for all Qt programs. it handles all of the important behind-the-scenes details that are vital to our program running properly. Creates a new Qt Label object and sets its text to Hello World. The nil argument will be explained shortly. 0 Resize the label to 150 pixels wide by 30 pixels tall to make sure the text is all visible. Assigns the label as the main widget of the application. Make the label visible. Calling exec is also known as starting the event loop. Finally we tell the application to start its processing. Comparing to C For comparison the equivalent C code is include include int main int argc char argv QApplication app argc argv QLabel label Hello world 0 BOOKLEET Report erratum Chapter 4. Get Your Feet Wet Objects and Widgets and parents oh my 21 150 30 label return Being the very astute reader you are .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.