[ Pobierz całość w formacie PDF ]
.The flag set named AbtKDEStandardon line 85 specifies which elements are to be used to make up the display.Table 5-2lists the flags and the element that each includes.The arguments on line 87 areused to tell the super class KDialogBasewhich buttons are to appear.In thisexample, there is an OK button, which will automatically close the window; anda Help button.The button specified on line 88 is the one that will be selectedwhen the dialog first opens.Cross- The description of KDialogBase in Chapter 4 explains how to make the OK andReferenceHelp buttons do what they re meant to do. 4682-1 ch05.f.qc 11/13/00 14:10 Page 106Part I &' Getting Started106Figure 5-4: A KAboutDialog with an image andtext pagesTable 5-2KAboutDialog Flags That Configure the DisplayFlag Name DescriptionAbtAppStandard Enables a combination of AbtTabbed, AbtTitle,and AbtProduct.AbtImageAndTitle Enables a combination of AbtPlain and AbtImageOnly.AbtImageLeft Displays the image on the left side of the window.AbtImageOnly Displays the image in the center because no other itemwill be beside it.AbtImageRight Displays the image on the right side of the window.AbtKDEStandard Enables a combination of AbtTabbed, AbtTitle,and AbtImageLeft.AbtPlain None of the default KAboutDialog components will bedisplayed.This can be used in combination with other flagsto customize the dialog.AbtProduce Displays the application name, the version, the author,and the date.AbtTabbed Displays a collection of one or more windows with tabsthat enable the user to switch from one to the other.AbtTitle Displays the title immediately beneath the title bar. 4682-1 ch05.f.qc 11/13/00 14:10 Page 107Chapter 5 &' The Predefined Dialogs107After the flags are set telling the dialog which of its elements it should display, it isstill necessary for you to supply the elements.Table 5-3 lists the methods that areavailable when using Constructor II.Table 5-3KAboutDialog Methods for Constructor IIMethod PurposeaddContainer() Adds a KAboutContainer that you can use to displaytext and imagesaddContainerPage() Adds a KAboutContainer as a tabbed page.You canuse it to display text and images.addPage() Adds an empty page to the collection of tabbed pages.You can use it to contain any widget you would liketo display.addTextPage() Adds a page of text to the collection of tabbed pagessetImage() Specifies the image that is to be displayed as the logosetImageBackground() Specifies the color to be used as background and fillwhen displaying the imagesetImageFrame() Enables or disables the frame around the image.The default is enabled.setProduct() Sets the four strings defining the name of theapplication, the version, the author, and the datesetTitle() Inserts the title at the top of the window (just underthe title bar)The call to setTitle()on line 93 is necessary because the flag setting includedAbtTitle, and it is necessary to supply the title to be displayed.The call to setCaption()on line 94 is a pass-through call to the super class to set the captiontext of the title bar at the top.The method calls on lines 95 through 97 specify the name of the file containingthe image to be used as a logo; the background color to be used behind the image;and whether the image is to have a border drawn around it.The background colorwill fill any areas not filled by the window, as previously shown in Figure 5-4, andwill also be the fill color for any transparent portion of the image.The default is tohave the border drawn, but the method setImageFram()can be used to turn it off. 4682-1 ch05.f.qc 11/13/00 14:10 Page 108Part I &' Getting Started108The method addTextPage()can be used a number of times  once for each pageyou wish to add to the tabbed window.As you can see by the examples on lines99 and 103, the only arguments are the string that is to become the label for thetab, and the text that is to become the body of the text.It is necessary to insertthe newline character  \n to format the text in multiple lines.The slot named appStandardAbout()beginning on line 109 produces the dialogshown in Figure 5-5.Figure 5-5: A KAboutDialog with headings andtabbed pagesThe text at the top of the window is set by two method calls.The call to setTitle()on line 116 sets the text of the title that is centered at the top.The call to setProduct()on line 121 sets the rest of the text.The two tabbed pages are addedby the calls to addTextPage()on lines 126 and 130.QFileDialogThe QFileDialogallows you to prompt the user for the name of a file or a directory [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • lo2chrzanow.htw.pl