// Instantiate a QToolButton object QToolButton *myButton = new QToolButton(this); // Instantiate an QAction object QAction *myAction = new QAction(QIcon(":/myIcon.png"), "My Action", this); //Sets the default action myButton->setDefaultAction(myAction);In this example, we create a QToolButton object and an QAction object. After that, we use setDefaultAction() method to connect the action to the button. One example of using QToolButton with setDefaultAction is in a toolbar where you have many icons for standard actions like cut, copy, paste, and undo. Setting the default action with each button allows you to keep the toolbar visible and ready for use. The library used for this example is QtGui from the Qt framework.