开发者

Qt - How to override a widget?

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开发者_StackOverflow中文版 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?


  • 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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜