How can I recognize a specific pattern of points entered by the user ?
-
Hi,
I'm working on a qt project. The user should input points to a screen on a mouse click. These points are braille dots, I want to translate these points to real characters. Is there a way in qt to recognize a specific pattern of points and finding relationships between dots entered to the screen ?
I used qgraphicsitem to perform some calculations is there functions i can use?
Note: I used a sliding window to recognize characters but I was told that the solution must be more dynamic. -
Hi and welcome to devnet,
Can you describe more precisely how the user should do that ? Does he have some sort of grid that he must click on to "write" the braille dots ?
An image of the current widget would be useful
-
Yes, the user clicks on a grid. I tried to use the positions of each point. Braille dots are arranged in 2 columns and 3 rows so I defined a sliding window that has 6 reference points and I calculated the distance from each point to each of the reference points. The points takes a flag that determines its position. But the sliding window is not a dynamic solution because of the fixed width and height.
-
Wouldn't be simpler to use them as "toggle switches" and map them on a translator class ?
a f
0 0 o 0 o 0
0 0 -> 0 0 -> 0 o
0 0 0 0 0 0You know that you have 6 points in a grid so numbering them e.g. from left to right and top to bottom you can recognize the a pattern when the point 0 is activated and f when the user adds point 3 (if the numbering starts from 0) etc. You are then independent of the size of the widget.
-
I will not have only 6 points. The user will write sentences not only characters. Can you describe more I don't understand you way of recognizing the pattern.
-
I thought so, the idea is that you create your braille char item and then re-use it as needed to create sentences. Something like:
@
class BrailleCharItem : public QGraphicsObject
{
Q_OBJECT
public:
BrailleCharItem();char toChar() const
{
// convert active points to char}
signals:
void charChanged(char brailleChar);private:
void processPoints() {
// call when a point has been clicked
char myChar = toChar();
emit charChanged(myChar);
}
};
@Then you can align these items to create complete phrases
-
Thank you. But I need you to describe the “toggle switches” if you have time.
-
Like a checkable QPushButton: click once on the point, set its "state" to checked and if another click happens state is unchecked. Then based on the checked state of your points you can return the corresponding char.