Melt 2 tablespoons of butter in a large skillet over medium heat. Add the onions and cook for 10 minutes, stirring occasionally.
Add the sugar and salt and cook for an additional 10 minutes, stirring occasionally until the onions are golden brown and caramelized.
Spread the remaining 2 tablespoons of butter on one side of each slice of bread.
Place two slices of bread butter-side down in the skillet. Top with a slice of cheese and then half of the caramelized onions. Top with another slice of cheese and then the remaining slice of bread, butter-side up.
Cook over medium heat until the bottom side is golden brown. Flip and cook until golden brown on the other side.