The error arises because the first argument to connect is wrong but there are several issues here.
Qt Code:
  1. QObject::connect(MainWindow->g_sld, SIGNAL(valueChanged (int)),SLOT(writeValue(int)));
To copy to clipboard, switch view to plain text mode 
  1. The compiler is expecting to see a pointer-to QObject. The identifier MainWindow is the name of a class not an object of that class, you would be closer with w.g_sld (w is not a pointer so not w->g_sld).
  2. The identifier g_sld is associated with a private member variable in the class MainWindow, and that is not accessible outside the class implementation.
  3. The three argument connect() can only be used inside a QObject implementation because the target object is an implied "this".


Move the connect() into the MainWindow implementation. Usually in the constructor after the setupUi().