1 line
6.7 KiB
JavaScript
1 line
6.7 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[15],{161:function(e,t,a){"use strict";a.d(t,"a",(function(){return r})),a.d(t,"b",(function(){return u}));var n=a(0),o=a.n(n),i=o.a.createContext({}),l=function(e){var t=o.a.useContext(i),a=t;return e&&(a="function"==typeof e?e(t):Object.assign({},t,e)),a},r=function(e){var t=l(e.components);return o.a.createElement(i.Provider,{value:t},e.children)};var c="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},s=Object(n.forwardRef)((function(e,t){var a=e.components,n=e.mdxType,i=e.originalType,r=e.parentName,c=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&-1===t.indexOf(n)&&(a[n]=e[n]);return a}(e,["components","mdxType","originalType","parentName"]),s=l(a),u=n,p=s[r+"."+u]||s[u]||d[u]||i;return a?o.a.createElement(p,Object.assign({},{ref:t},c,{components:a})):o.a.createElement(p,Object.assign({},{ref:t},c))}));function u(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var i=a.length,l=new Array(i);l[0]=s;var r={};for(var d in t)hasOwnProperty.call(t,d)&&(r[d]=t[d]);r.originalType=e,r[c]="string"==typeof e?e:n,l[1]=r;for(var u=2;u<i;u++)l[u]=a[u];return o.a.createElement.apply(null,l)}return o.a.createElement.apply(null,a)}s.displayName="MDXCreateElement"},55:function(e,t,a){"use strict";a.r(t),a.d(t,"frontMatter",(function(){return l})),a.d(t,"rightToc",(function(){return r})),a.d(t,"default",(function(){return s}));a(0);var n=a(161);function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e}).apply(this,arguments)}function i(e,t){if(null==e)return{};var a,n,o=function(e,t){if(null==e)return{};var a,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||(o[a]=e[a]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(o[a]=e[a])}return o}var l={sidebar_label:"NodeLayout",title:"NodeLayout"},r=[{value:"Example",id:"example",children:[]},{value:"Static Methods",id:"static-methods",children:[]},{value:"Instance Properties",id:"instance-properties",children:[{value:"layout.type",id:"layouttype",children:[]}]},{value:"Instance Methods",id:"instance-methods",children:[{value:"layout.addWidget(childWidget, ...args)",id:"layoutaddwidgetchildwidget-args",children:[]},{value:"layout.activate()",id:"layoutactivate",children:[]},{value:"layout.invalidate()",id:"layoutinvalidate",children:[]},{value:"layout.update()",id:"layoutupdate",children:[]}]}],c={rightToc:r},d="wrapper";function s(e){var t=e.components,a=i(e,["components"]);return Object(n.b)(d,o({},c,a,{components:t,mdxType:"MDXLayout"}),Object(n.b)("blockquote",null,Object(n.b)("p",{parentName:"blockquote"},"Abstract class to add functionalities common to all Layout.")),Object(n.b)("p",null,Object(n.b)("strong",{parentName:"p"},"This class implements all methods, properties of Qt's ",Object(n.b)("a",o({parentName:"strong"},{href:"https://doc.qt.io/qt-5/qlayout.html"}),"QLayout class")," so that it can be inherited by all layouts")),Object(n.b)("p",null,Object(n.b)("inlineCode",{parentName:"p"},"NodeLayout")," is an abstract class and hence no instances of the same should be created. It exists so that we can add similar functionalities to all layout's easily. Additionally it helps in typechecking process."),Object(n.b)("p",null,Object(n.b)("strong",{parentName:"p"},"NodeLayout is the base class for all layouts. It inherits from another abstract class ",Object(n.b)("a",o({parentName:"strong"},{href:"/docs/api/Component"}),"Component"))),Object(n.b)("h3",{id:"example"},"Example"),Object(n.b)("pre",null,Object(n.b)("code",o({parentName:"pre"},{className:"language-javascript"}),'const {\n NodeLayout,\n NodeWidget,\n FlexLayout,\n GridLayout,\n QPushButton,\n QWidget\n} = require("@nodegui/nodegui");\n\n// addChildToLayout can accept any layout since it expects NodeLayout\nconst addChildToLayout = (layout: NodeLayout, widget: NodeWidget) => {\n layout.addWidget(widget);\n};\n\naddChildToLayout(new FlexLayout(), new QPushButton());\naddChildToLayout(new GridLayout(), new QWidget());\n')),Object(n.b)("p",null,"NodeLayout will list all methods and properties that are common to all layouts in the NodeGui world."),Object(n.b)("h2",{id:"static-methods"},"Static Methods"),Object(n.b)("p",null,"NodeLayout can access all the static methods defined in ",Object(n.b)("a",o({parentName:"p"},{href:"/docs/api/Component"}),"Component")),Object(n.b)("h2",{id:"instance-properties"},"Instance Properties"),Object(n.b)("p",null,"NodeLayout can access all the instance properties defined in ",Object(n.b)("a",o({parentName:"p"},{href:"/docs/api/Component"}),"Component")),Object(n.b)("p",null,"Additionally it also has the following instance properties:"),Object(n.b)("h3",{id:"layouttype"},Object(n.b)("inlineCode",{parentName:"h3"},"layout.type")),Object(n.b)("p",null,"This will return the string ",Object(n.b)("inlineCode",{parentName:"p"},"layout")," for all layouts."),Object(n.b)("h2",{id:"instance-methods"},"Instance Methods"),Object(n.b)("p",null,"NodeLayout can access all the instance methods defined in ",Object(n.b)("a",o({parentName:"p"},{href:"/docs/api/Component"}),"Component")),Object(n.b)("p",null,"Additionally it also has the following instance methods:"),Object(n.b)("h3",{id:"layoutaddwidgetchildwidget-args"},Object(n.b)("inlineCode",{parentName:"h3"},"layout.addWidget(childWidget, ...args)")),Object(n.b)("p",null,"This is an abstract method in NodeLayout class. All Layouts inheriting from NodeLayout should implement this method."),Object(n.b)("ul",null,Object(n.b)("li",{parentName:"ul"},Object(n.b)("inlineCode",{parentName:"li"},"childWidget")," NodeWidget - Any widget in the NodeGui world."),Object(n.b)("li",{parentName:"ul"},Object(n.b)("inlineCode",{parentName:"li"},"...args")," any[] - Additional params as required by the layout.")),Object(n.b)("h3",{id:"layoutactivate"},Object(n.b)("inlineCode",{parentName:"h3"},"layout.activate()")),Object(n.b)("p",null,"Redoes the layout for parent widget of this layout if necessary. Returns true if the layout was redone."),Object(n.b)("h3",{id:"layoutinvalidate"},Object(n.b)("inlineCode",{parentName:"h3"},"layout.invalidate()")),Object(n.b)("p",null,"Invalidates any cached information in this layout."),Object(n.b)("h3",{id:"layoutupdate"},Object(n.b)("inlineCode",{parentName:"h3"},"layout.update()")),Object(n.b)("p",null,"Updates the layout for parent widget of this layout. You should generally not need to call this because it is automatically called at the most appropriate times."))}s.isMDXComponent=!0}}]); |