#includeint main(int argc, char *argv[]) { QApplication a(argc, argv); QLabel myLabel("Default text"); myLabel.setText("Hello World!"); myLabel.show(); return a.exec(); }
#includeIn conclusion, the Label setText function or method is widely used in various GUI frameworks like Qt, MFC, wxWidgets, and more. The package or library used in these examples is Qt and MFC, respectively.class CMyDialog : public CDialog { public: CMyDialog(UINT nIDTemplate, CWnd* pParent = NULL) : CDialog(nIDTemplate, pParent) {} virtual BOOL OnInitDialog() { if (!CDialog::OnInitDialog()) return FALSE; CStatic* pStatic = (CStatic*)GetDlgItem(IDC_MY_LABEL); pStatic->SetWindowText(_T("Welcome to my app!")); return TRUE; } }; int main() { CMyDialog dlg(IDD_DIALOG1); dlg.DoModal(); return 0; }