Ok so I am building a GUI for a Rubik's Solving Robot. I am currently working on developing the GUI to be able to click the squares of the rubiks cube and they change colors to the correct color. I am using a grid with QLabels that I want to pass to my function to do the processing.
MainWindow.h
In my header file I have :
void mouse_pressed
(int i,
int j,
QLabel* cubieface
);
void mouse_pressed(int i, int j,QLabel* cubieface);
To copy to clipboard, switch view to plain text mode
MainWindow.cpp
// This is my function for Left Face 0 cube and I want to pass the int i, j for the position of the array cube[6][9] and QLabel name so I can update the setPixMap(Color) when the Mouse is pressed. The function will change the color of the square based on the # in the array. :
void MainWindow::l_f_0_clicked()
{
this->mouse_pressed(1,0,Ui_MainWindow::cubie_left_0); // This is where the problem arises :mad: line 44 error in code
}
// Mouse Pressed function
void MainWindow
::mouse_pressed(int i,
int j,
QLabel *cubieface
) {
QPixmap whitepix
("/Users/RubiksGUI/white.png");
QPixmap redpix
("/Users/RubiksGUI/red.png");
QPixmap greenpix
("/Users/RubiksGUI/green.png");
QPixmap yellowpix
("/Users/RubiksGUI/yellow.png");
QPixmap orangepix
("/Users/RubiksGUI/orange.png");
QPixmap bluepix
("/Users/RubiksGUI/blue.png");
if(cubedev[i][j]==5)
{
cubieface->setPixmap(whitepix); //:mad: Also once corrected this is usually ui->cubieface->setPixmap(color) but isnt throwing an error for it without the ui-> part
cubedev[i][j]=0;
}
else if(cubedev[i][j]==0)
{
cubieface->setPixmap(redpix);
cubedev[i][j]+=1;
}
// This is my function for Left Face 0 cube and I want to pass the int i, j for the position of the array cube[6][9] and QLabel name so I can update the setPixMap(Color) when the Mouse is pressed. The function will change the color of the square based on the # in the array. :
void MainWindow::l_f_0_clicked()
{
this->mouse_pressed(1,0,Ui_MainWindow::cubie_left_0); // This is where the problem arises :mad: line 44 error in code
}
// Mouse Pressed function
void MainWindow::mouse_pressed(int i, int j, QLabel *cubieface)
{
QPixmap whitepix("/Users/RubiksGUI/white.png");
QPixmap redpix("/Users/RubiksGUI/red.png");
QPixmap greenpix("/Users/RubiksGUI/green.png");
QPixmap yellowpix("/Users/RubiksGUI/yellow.png");
QPixmap orangepix("/Users/RubiksGUI/orange.png");
QPixmap bluepix("/Users/RubiksGUI/blue.png");
if(cubedev[i][j]==5)
{
cubieface->setPixmap(whitepix); //:mad: Also once corrected this is usually ui->cubieface->setPixmap(color) but isnt throwing an error for it without the ui-> part
cubedev[i][j]=0;
}
else if(cubedev[i][j]==0)
{
cubieface->setPixmap(redpix);
cubedev[i][j]+=1;
}
To copy to clipboard, switch view to plain text mode
... Etc for each case. My problem is the function l_f_0_clicked() wont pass the QLabel.
Error : ../RubiksGUI/mainwindow.cpp:62:44: error: invalid use of non-static data member 'cubie_left_0'
this->mouse_pressed(1,0,Ui_MainWindow::cubie_left_0);
HELP PLEASE!!!!!
Bookmarks