akudewan
September 26th, 2007, 01:46 PM
Hello,
I'm making a Sudoku (solving/generating) program in Qt. Now, I'm just a beginner as a programmer, and I have no experience with Qt. I'm stuck in a strange situation. I want to connect a signal and slot with different parameters.
My grid is made up of an array of QLineEdits, and here's how I'm making the connections:
/* Making connections */
for(minigrid=0;minigrid<9;minigrid++)
{
for(row=0;row<3;row++)
{
for(column=0;column<3;column++)
{
connect(box[minigrid][row][column], SIGNAL(returnPressed()), this, SLOT(checkInput(int, int int)));
}
}
}
The 3 parameters of checkInput() are the minigrid, row and column numbers of the respective box in the grid. Qt doesn't accept Signals and Slots with different parameters, so how do I go about doing this?
Do I:
1) Overload returnPressed() of QLineEdit ? Is this even possible?
2) Create my own Signal in the Grid class? If so, how do I connect this signal to returnPressed() ? (if I do, then both will need to have void parameters. What how do I get the values of minigrid, row and column then?)
3) Change the structure of my grid? Use 81 connect statements ?
4) Can I subclass QLineEdit, and make my own signal in it?
Any help with this will be greatly appreciated...
I'm making a Sudoku (solving/generating) program in Qt. Now, I'm just a beginner as a programmer, and I have no experience with Qt. I'm stuck in a strange situation. I want to connect a signal and slot with different parameters.
My grid is made up of an array of QLineEdits, and here's how I'm making the connections:
/* Making connections */
for(minigrid=0;minigrid<9;minigrid++)
{
for(row=0;row<3;row++)
{
for(column=0;column<3;column++)
{
connect(box[minigrid][row][column], SIGNAL(returnPressed()), this, SLOT(checkInput(int, int int)));
}
}
}
The 3 parameters of checkInput() are the minigrid, row and column numbers of the respective box in the grid. Qt doesn't accept Signals and Slots with different parameters, so how do I go about doing this?
Do I:
1) Overload returnPressed() of QLineEdit ? Is this even possible?
2) Create my own Signal in the Grid class? If so, how do I connect this signal to returnPressed() ? (if I do, then both will need to have void parameters. What how do I get the values of minigrid, row and column then?)
3) Change the structure of my grid? Use 81 connect statements ?
4) Can I subclass QLineEdit, and make my own signal in it?
Any help with this will be greatly appreciated...