Qt 5.10 Book Examples
MacButton.mm
Go to the documentation of this file.
1 // ======================================================================
2 // MacButton.mm
3 // ======================================================================
4 // This file is a part of the book
5 // "Qt 5.10 Professional programming with C++"
6 // http://qt-book.com
7 // ======================================================================
8 // Copyright (c) 2017 by Max Schlee
9 // ======================================================================
10 
11 #import "MacButton.h"
12 #import <Cocoa/Cocoa.h>
13 #include <QtWidgets>
14 
15 // ----------------------------------------------------------------------
17  : QMacCocoaViewContainer(0, pwgt)
18 {
19  NSAutoreleasePool* ppool = [[NSAutoreleasePool alloc] init];
20 
21  NSButton* pcmd = [[NSButton alloc] init];
22 
23  [pcmd setButtonType:NSSwitchButton];
24  [pcmd setTitle:@"Mac Check Button"];
25  [pcmd setState:YES];
26 
27  setCocoaView(pcmd);
28 
29  [pcmd release];
30  [ppool release];
31 }
32 
33 // ----------------------------------------------------------------------
35 {
36  return QSize(150, 40);
37 }
38 
39 // ----------------------------------------------------------------------
40 MacButton::MacButton(QWidget* pwgt) : QWidget(pwgt/*=0*/)
41 {
42  ButtonContainer* pcmd = new ButtonContainer(this);
43 
44  QVBoxLayout* pvbx = new QVBoxLayout;
45  pvbx->setContentsMargins(0, 0, 0, 0);
46  pvbx->addWidget(pcmd);
47  setLayout(pvbx);
48 }
49 
QSize sizeHint() const
Definition: MacButton.mm:34
MacButton(QWidget *pwgt=0)
Definition: MacButton.mm:40
ButtonContainer(QWidget *pwgt=0)
Definition: MacButton.mm:16