Advertisement
Guest User

Untitled

a guest
Apr 5th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.15 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "github.com/therecipe/qt/widgets"
  5.     "os"
  6. )
  7.  
  8. func main() {
  9.     // Create application
  10.     app := widgets.NewQApplication(len(os.Args), os.Args)
  11.  
  12.     // Create main window
  13.     window := widgets.NewQMainWindow(nil, 0)
  14.     window.SetWindowTitle("Hello World Example")
  15.     window.SetMinimumSize2(200, 200)
  16.  
  17.     // Create main layout
  18.     layout := widgets.NewQVBoxLayout()
  19.  
  20.     // Create main widget and set the layout
  21.     mainWidget := widgets.NewQWidget(nil, 0)
  22.     mainWidget.SetLayout(layout)
  23.  
  24.     // Create a line edit and add it to the layout
  25.     input := widgets.NewQLineEdit(nil)
  26.     input.SetPlaceholderText("1. write something")
  27.     layout.AddWidget(input, 0, 0)
  28.  
  29.     // Create a button and add it to the layout
  30.     button := widgets.NewQPushButton2("2. click me", nil)
  31.     layout.AddWidget(button, 0, 0)
  32.  
  33.     // Connect event for button
  34.     button.ConnectClicked(func(checked bool) {
  35.         widgets.QMessageBox_Information(nil, "OK", input.Text(),
  36.             widgets.QMessageBox__Ok, widgets.QMessageBox__Ok)
  37.     })
  38.  
  39.     // Set main widget as the central widget of the window
  40.     window.SetCentralWidget(mainWidget)
  41.  
  42.     // Show the window
  43.     window.Show()
  44.  
  45.     // Execute app
  46.     app.Exec()
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement