Question

I've created a form using the Qt designer which includes a QToolButton.
I can turn it using ui->favouriteToolButton.
I used the designer because it's much more simple then code all the gui.

Problem is that specifically for this ToolButton i want to code by creating its own class:

class FavouriteMenu : public QToolButton
{
    Q_OBJECT

public:
    explicit FavouriteMenu(QWidget *parent = 0);
    //~FavouriteMenu();

private:
    QMenu *menu;                                        //MENU
    QAction *addToBookmarkAct;
    QAction *editBookmarkAct;

...

I want to be able to override ui->favouriteToolButton with a new instance of FavouriteMenu. How can i do it?

Was it helpful?

Solution

  • Right click on the button in designer and select "Promote To..."
  • Under Promoted class name enter "FavouriteMenu"
  • Under Header File enter the filename of the .h file
  • Click "Add"
  • Click "Promote"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top