Advertisement
hman

Qyoto problem using QFileDialog

Oct 27th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 KB | None | 0 0
  1. using System;
  2. using Qyoto;
  3.  
  4. namespace testqyotoproject
  5. {
  6.  
  7.     public static class Program
  8.     {
  9.  
  10.         [STAThread]
  11.         public static int Main(String[] args)
  12.         {
  13.             new QApplication(args);
  14.             new QyotoApp();
  15.             return QApplication.Exec();
  16.         }
  17.     }
  18.  
  19.  
  20.  
  21.     public class QyotoApp: QWidget
  22.     {
  23.         /// <summary>
  24.         /// Constructor
  25.         /// </summary>
  26.         public QyotoApp()
  27.         {
  28.             WindowTitle = "Qyoto Test Application";
  29.  
  30.             InitUI();
  31.  
  32.             Resize(300, 80);
  33.             Move(300, 300);
  34.             Show();
  35.         }
  36.  
  37.  
  38.  
  39.  
  40.         void InitUI()
  41.         {
  42.             QVBoxLayout vbox = new QVBoxLayout(this);
  43.             QPushButton ok = new QPushButton("Click here to open file dialog", this);
  44.             Connect( ok, SIGNAL("clicked()"), this, SLOT("ShowDialog()"));
  45.             vbox.AddWidget(ok, 0, (uint)AlignmentFlag.AlignCenter);
  46.  
  47.             this.SetLayout(vbox);
  48.         }
  49.  
  50.  
  51.  
  52.  
  53.         [Q_SLOT]
  54.         void ShowDialog()
  55.         {
  56.             string selectedFile = QFileDialog.GetOpenFileName(this, "File Open Dialog");
  57.  
  58.             if (string.IsNullOrEmpty(selectedFile))
  59.             {
  60.                 return;
  61.             }
  62.  
  63.             Console.WriteLine("selected file: " + selectedFile);
  64.         }
  65.  
  66.     }
  67. }
  68.  
  69. // end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement