Results 1 to 4 of 4

Thread: Passing QLabel as an argument in a function error: invalid use of non-static data mem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2016
    Posts
    2
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows

    Default Passing QLabel as an argument in a function error: invalid use of non-static data mem

    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 :
    Qt Code:
    1. void mouse_pressed(int i, int j,QLabel* cubieface);
    To copy to clipboard, switch view to plain text mode 



    MainWindow.cpp

    Qt Code:
    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. :
    2.  
    3. void MainWindow::l_f_0_clicked()
    4. {
    5. this->mouse_pressed(1,0,Ui_MainWindow::cubie_left_0); // This is where the problem arises :mad: line 44 error in code
    6. }
    7.  
    8. // Mouse Pressed function
    9. void MainWindow::mouse_pressed(int i, int j, QLabel *cubieface)
    10. {
    11.  
    12. QPixmap whitepix("/Users/RubiksGUI/white.png");
    13. QPixmap redpix("/Users/RubiksGUI/red.png");
    14. QPixmap greenpix("/Users/RubiksGUI/green.png");
    15. QPixmap yellowpix("/Users/RubiksGUI/yellow.png");
    16. QPixmap orangepix("/Users/RubiksGUI/orange.png");
    17. QPixmap bluepix("/Users/RubiksGUI/blue.png");
    18. if(cubedev[i][j]==5)
    19. {
    20. 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
    21. cubedev[i][j]=0;
    22.  
    23. }
    24. else if(cubedev[i][j]==0)
    25. {
    26. cubieface->setPixmap(redpix);
    27. cubedev[i][j]+=1;
    28.  
    29. }
    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!!!!!
    Last edited by anda_skoa; 19th April 2016 at 09:35. Reason: missing [code] tags

Similar Threads

  1. Replies: 1
    Last Post: 3rd May 2013, 16:07
  2. onclick event passing argument to js function
    By dyngoman in forum Qt Programming
    Replies: 0
    Last Post: 10th September 2011, 13:51
  3. Building static Qt. Error 126 invalid argument
    By kea_ in forum Installation and Deployment
    Replies: 2
    Last Post: 20th March 2011, 07:58
  4. Replies: 3
    Last Post: 17th July 2008, 07:43
  5. QtScript : passing array as argument into function
    By derek_r in forum Qt Programming
    Replies: 4
    Last Post: 27th October 2007, 10:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.