Skip to content

Instantly share code, notes, and snippets.

@johanalkstal
Last active March 22, 2021 08:17
Show Gist options
  • Save johanalkstal/7c0d2fd29d712e95bfea0e75fd85b200 to your computer and use it in GitHub Desktop.
Save johanalkstal/7c0d2fd29d712e95bfea0e75fd85b200 to your computer and use it in GitHub Desktop.
ScrollArea
import { FlexLayout, QBoxLayout, QLabel, QScrollArea, QWidget, ScrollBarPolicy } from "@nodegui/nodegui"
import { Color, Space, TextSize } from "../style/variables"
class MessageList extends QScrollArea {
constructor() {
super()
this.setVerticalScrollBarPolicy(ScrollBarPolicy.ScrollBarAlwaysOn)
this.setWidgetResizable(true)
this.setInlineStyle(`
flex: 1;
`)
const container = new QWidget()
container.setLayout(new FlexLayout())
container.setInlineStyle(`
background-color: ${Color.white};
flex-direction: column;
padding: ${Space.md};
`)
container.setStyleSheet(`
QLabel {
font-size: ${TextSize.sm};
margin-bottom: ${Space.xs};
min-height: 18px;
}
`)
this.setWidget(container)
}
addMessage(message: string, color = Color.black) {
const label = new QLabel()
label.setText(message)
label.setInlineStyle(`
color: ${color};
`)
this.contentWidget?.layout?.addWidget(label)
}
}
export default MessageList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment