PDA

View Full Version : multiply a widget by pushing a button



mifmef
25th October 2015, 17:16
Hi everybody,
I'm quite new in Qt programming and i'm facing a problem.
Here is what I want to do :
going from
11471
to
11472

by pushing the 'Add' button.
I'veput the 3 comboboxes in a gridlayout and trying to insert signal/slot in to the 'Add' button to multiply le layout but it doesnt work. I'm doing this under Qt Designer.

Please help and sorry for my english i'm not fluent.

Thanks

ars
25th October 2015, 19:17
Hello,

so what's your problem with this? What have you tried so far?

Here is how I would do it, assuming that your grid layout is in the main window:
1. Create a slot addRow() to your main window class and connect that to your Add button. Connection can be done in designer.
2. Implement the addRow() method to work as follows:
- determine the current number of rows of your grid layout and store it in a variable rows (http://doc.qt.io/qt-4.8/qgridlayout.html#rowCount)
- Add 3 new QComboBox instances into a new row (corresponding to row index rows) and columns 0, 1, 2. See http://doc.qt.io/qt-4.8/qgridlayout.html#addWidget

Best regards
ars