Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3227874
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:37:33+00:00 2026-05-17T16:37:33+00:00

Qt3 used to provide QMenuBar::insertItem with QWidget* parameter. This way any custom widget could

  • 0

Qt3 used to provide QMenuBar::insertItem with QWidget* parameter. This way any custom widget could be added to menu bar – for example a clock-widget.
In Qt4 there is no such overloaded method. What would be the best way to reach the same goal – adding custom widgets to a menu bar? The custom widgets should be integrated in the layout of menu bar.
Does anyoune knows the background, why this overload of insertItem was removed in Qt4 API?

Best regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:37:33+00:00Added an answer on May 17, 2026 at 4:37 pm

    Sorry Javier for short comments. Every time I intended to break a line, the comment was submitted 🙁

    I tried this code in a project created with QtCreator:

    class MyWidgetAction : public QWidgetAction
    {
    public:
        MyWidgetAction( QObject * parent ) :QWidgetAction (  parent )
        {
    
        }
        void releaseWidget ( QWidget * widget )
        {
            widget->deleteLater();
        }
    
        QWidget * requestWidget ( QWidget * parent )
        {
            QPushButton *b = new QPushButton( tr("MyWidget"), parent );
            b->show();
            return b;
        }
    };
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);    
        QAction *a = new QAction(tr("TestAction"),this); //1
        QWidgetAction * wa = new QWidgetAction(this);    //2
        wa->setDefaultWidget(new QPushButton("Default"));
        MyWidgetAction *mwa = new MyWidgetAction(this);  //3
    
        ui->menuBar->addAction( a ); //1 - works. TestAction added to menu bar
        ui->menuBar->addAction( wa ); //2 - noop. nothing added to menu bar
        ui->menuBar->addAction( mwa ); //3 - noop. nothing added to menu bar
    }
    

    Only adding QAction (1) worked. Neither adding QWidgetAction with default widget not subclassing QWidgetAction gave a result. I’ve set breakpoints in C-Tor and both virtual functions of MyWidgetAction. Surprisingly, only C-Tor break-point was hit.
    I’ve tried on Windows with Open-Source, MinGW version of Qt4.6.3
    Could it be a bug in Qt?
    Thank you very much in advance for any suggestions!

    Regards,
    Valentin Heinitz

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Qt3.3 used to allow for multiple selections in the QTextEdit widget by calling the
Is there a way in Qt3 to convert QDateTime into a QString and back
It looks as if their was a solution for this in qt3, but I
From the screenshot featured on this page http://www.kde.gr.jp/~ichi/qt/designer-manual-3.html it seems like this functionality was
I am porting an application from Qt3 to Qt4, and need a Qt4 replacement
I am porting an application from QT3 to QT4, and keep running into problems
I want to create a window with a variable number of custom widgets, each
When I try to do any svn command and supply the --username and/or --password
Hey. I'm working on a project, porting a software from Qt3 to Qt4. Its
I am working on VS2005 sp2, with qt3.3.7. I have set the linkers>system>subsystem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.