Incorrect display of labels and default responses in `QInputDialog` widgets
SN2014J opened this issue · comments
Describe the bug
QInputDialog
labels and default responses display incorrectly if they are greater than 21 characters long.
Below I show the minimized files that I used, i.e. package.json
, tsconfig.json
and src/index.js
, as well as the sequence of terminal commands that I used to install, build and run the demonstration app. The key lines are near the end of src/index.js
.
To Reproduce
package.json
:
{ "name": "verify-qinputdialog-bug", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "dev": "npm run build && ./node_modules/@nodegui/nodegui/scripts/qode.js dist/index.js", "build": "tsc && npm run build:addon", "install": "npm run setupqt && (node ./node_modules/@nodegui/nodegui/scripts/skip.js || npm run setupbinary || npm run build:addon)", "setupqt": "node ./node_modules/@nodegui/nodegui/scripts/setupMiniQt.js", "setupbinary": "node ./node_modules/@nodegui/nodegui/scripts/setupBinary.js", "build:addon": "./node_modules/cross-env/src/bin/cross-env.js CMAKE_BUILD_PARALLEL_LEVEL=8 ./node_modules/cmake-js/bin/cmake-js --directory=./node_modules/@nodegui/nodegui compile", "qode": "node ./node_modules/@nodegui/nodegui/scripts/qode.js" }, "devDependencies": { "@types/bindings": "^1.5.1", "@types/node": "^16.4.13", "clang-format": "^1.5.0", "typescript": "^4.3.5" }, "dependencies": { "@nodegui/nodegui": "^0.57.1", "@nodegui/artifact-installer": "^1.1.0", "@nodegui/qode": "^16.4.3", "cmake-js": "^6.2.1", "cross-env": "^7.0.3", "cuid": "^2.1.8", "manage-path": "^2.0.0", "memoize-one": "^5.2.1", "node-addon-api": "^4.0.0", "tar": "^6.0.1" }, "bin": { "qode": "./node_modules/@nodegui/nodegui/scripts/qode.js" }, "engineStrict": false, "engines": { "node": ">=14.x.x" }, "typings": "dist/index.d.ts" }
tsconfig.json
:
{ "compilerOptions": { "target": "ES2021", "declaration": true, "sourceMap": false, "outDir": "./dist", "strict": true, "strictNullChecks": false, "moduleResolution": "node", "esModuleInterop": true, "resolveJsonModule": true, "allowJs": true }, "include": ["src"], "exclude": ["src/rust"], "typedocOptions": { "mode": "file", "out": "website/docs/api/generated", "plugin": ["typedoc-plugin-markdown"], "excludeExternals": true, "excludeNotExported": true, "excludePrivate": true, "excludeProtected": true, "includeDeclarations": true, "hideBreadcrumbs": true, "hideSources": true, "theme": "docusaurus2" } }
src/index.js
:
const { QMainWindow, QWidget, QMessageBox, QInputDialog, QPushButton, ButtonRole } = require("@nodegui/nodegui"); const win = new QMainWindow(); const centralWidget = new QWidget(); win.setCentralWidget(centralWidget); win.show(); global.win = win; const messageBox = new QMessageBox( centralWidget ); const okButton = new QPushButton(); // Message box widgets can show messages significantly longer than 21 characters. messageBox.setText('The message box widget is apparently able to show messages of significant length, and certainly greater than 21 characters.'); okButton.setText('OK'); messageBox.addButton(okButton, ButtonRole.AcceptRole); messageBox.exec(); // Input dialog widgets correctly show labels and default responses up to 21 characters in length. // However, labels and/or default responses longer than 21 characters in length appear // as short changing arbitrary messages. const dialogA = new QInputDialog(centralWidget); const dialogB = new QInputDialog(centralWidget); const dialogC = new QInputDialog(centralWidget); dialogA.setLabelText('label A .............'); // 21 chars -----> works dialogB.setLabelText('label B ..............'); // 22 chars -----> does not work dialogC.setLabelText('label C .............'); // 21 chars -----> works dialogA.setTextValue('input A .............'); // 21 chars -----> works dialogB.setTextValue('input B .............'); // 21 chars -----> works dialogC.setTextValue('input C ..............'); // 22 chars -----> does not work dialogA.exec(); dialogB.exec(); dialogC.exec();
terminal commands:
npm install npm run build npm run dev
When the above commands are run, the visible app shows correct output for some but not all of the QInputDialog
widgets.
Expected behavior
All of the QInputDialog
widget labels and default responses should show as plain text.
Screenshots
correct display in QMessageBox
widget even with longer string:
correct display in QInputDialog
widget with labels and default responses that are 21 characters long:
incorrect display in QInputDialog
widget of label that is 22 characters long; note that multiple runs of the identical code produce different apparently arbitrary incorrect labels, including blank labels on occasion, as shown:
incorrect display in QInputDialog
widget of default response that is 22 characters long; note that multiple runs of the identical code produce different apparently arbitrary incorrect default responses (only a single screen shot is shown, but the difference between otherwise identical runs is comparable to the differences shown in the screen shots for labels above):
Desktop:
- OS: Mac
- NodeGUI version: 0.57.1
- OS Version: 12.6
You should retest this on the latest NodeGui versions. They are running on Qt6 now instead of Qt5.
I have now, to the best of my knowledge, updated my test project to the latest NodeGui version, i.e. v0.60.0. In the installation notes that appear in my console during installation, it seems to indicate install/use of Qt 6.4.1, as you suggested @sedwards2009 .
However, the problems discussed above seem to persist, and in fact may be worse. As before, a QMessageBox seems to work correctly, as shown here:
However, now none of QInputDialog labels or default responses of any length (i.e. whether 21 characters or more) seem to work properly, as shown here:
For the record, I did not change my src/index.js
file. My attempts to update nodegui resulted in the following package.json
file contents:
{ "name": "verify-qinputdialog-bug", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "dev": "npm run build && ./node_modules/@nodegui/nodegui/scripts/qode.js dist/index.js", "build": "tsc && npm run build:addon", "install": "npm run setupqt && (node ./node_modules/@nodegui/nodegui/scripts/skip.js || npm run setupbinary || npm run build:addon)", "setupqt": "node ./node_modules/@nodegui/nodegui/scripts/setupMiniQt.js", "setupbinary": "node ./node_modules/@nodegui/nodegui/scripts/setupBinary.js", "build:addon": "./node_modules/cross-env/src/bin/cross-env.js CMAKE_BUILD_PARALLEL_LEVEL=8 ./node_modules/cmake-js/bin/cmake-js --directory=./node_modules/@nodegui/nodegui compile", "qode": "node ./node_modules/@nodegui/nodegui/scripts/qode.js" }, "devDependencies": { "@types/bindings": "^1.5.1", "@types/node": "^16.4.13", "clang-format": "^1.5.0", "typescript": "^4.9.5" }, "dependencies": { "@nodegui/artifact-installer": "^1.1.0", "@nodegui/nodegui": "^0.60.0", "@nodegui/qode": "^16.4.3", "cmake-js": "^6.2.1", "cross-env": "^7.0.3", "cuid": "^2.1.8", "manage-path": "^2.0.0", "memoize-one": "^5.2.1", "node-addon-api": "^4.0.0", "tar": "^6.0.1" }, "bin": { "qode": "./node_modules/@nodegui/nodegui/scripts/qode.js" }, "engineStrict": false, "engines": { "node": ">=14.x.x" }, "typings": "dist/index.d.ts" }