Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widgets render incorrectly #993

Open
scanline opened this issue Feb 1, 2023 · 1 comment
Open

Widgets render incorrectly #993

scanline opened this issue Feb 1, 2023 · 1 comment

Comments

@scanline
Copy link

scanline commented Feb 1, 2023

To get going, I followed James Hibbard's Getting started guide on creating
a NodeGUI powered Password Generator application.
Inside it's using a QWidget, holding two instances of QPushButton arranged in a FlexLayout.
Unfortunately the two buttons - which should be sized equally - look wrong.

So on Windows 10 it looks like this:
nodeGUIWIN1

and on macOS Catalina:
nodeGUIMAC1

To reproduce this bug, simply clone the starter repo:

git clone https://github.com/nodegui/nodegui-starter

and use the following index.js

import { QMainWindow, QWidget, FlexLayout, QPushButton } from '@nodegui/nodegui';

const win = new QMainWindow();
win.resize(400, 200);

const view = new QWidget();
view.setObjectName("rootView")
const layout1 = new FlexLayout();
view.setLayout(layout1);
win.setCentralWidget(view);

const view3 = new QWidget();
view3.setObjectName("buttonRow");
const layout4 = new FlexLayout();
view3.setLayout(layout4);
layout1.addWidget(view3);

const button1 = new QPushButton();
button1.setObjectName("generateButton");
button1.setText("Generate");
layout4.addWidget(button1);

const button2 = new QPushButton();
button2.setObjectName("copyButton")
button2.setText("Copy to clipboard");
layout4.addWidget(button2);

win.setStyleSheet(`
	#rootView {
		padding: 5px;
	}

	#buttonRow {
		margin-bottom: 5px;
		flex-direction: 'row';
	}
	#generateButton {
		width: 120px;
		margin-right: 3px;
	}
	#copyButton {
		width: 120px;
	}
`);

win.show();
global.win = win;

Furthermore while digging through the API I stumbled upon the QGroupBox widget. Basically it should draw a box, a title and any child widgets somewhere within the surrounding box.
Sadly this also renders incorrectly.
nodeGUIWIN2

nodeGUIMAC2

import { QMainWindow, QWidget, FlexLayout,QRadioButton, QGroupBox} from '@nodegui/nodegui';

const win = new QMainWindow();

const centralWidget = new QWidget();
const rootLayout = new FlexLayout();
centralWidget.setLayout(rootLayout);

const r1 = new QRadioButton();
r1.setText('R1');
const r2 = new QRadioButton();
r2.setText('R2');
const r3 = new QRadioButton();
r3.setText('R3');
const groupBoxLayout = new FlexLayout();
const groupBox = new QGroupBox();
groupBox.setTitle("group")
groupBox.setLayout(groupBoxLayout);
groupBoxLayout.addWidget(r1);
groupBoxLayout.addWidget(r2);
groupBoxLayout.addWidget(r3);

rootLayout.addWidget(groupBox);

win.setCentralWidget(centralWidget);
win.show();

global.win = win;

Both examples utilize the starter repo - which is using NodeGUI v0.57.1. Upgrading to v0.58.0-rc4 did not resolve the issue.

@sedwards2009
Copy link
Collaborator

The flex layout stuff doesn't play quite as well with the normal Qt layouts as you would like. If you want to use the Qt layouts it probably works best if you don't mix in any flex layouts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants