QPrintPreviewDialog add QMenuBar



  • Hi all
    I have problem with the class QPrintPreviewDialog , adding QMenuBar with the next code:
    @
    QPrintPreviewDialog *dialog = new QPrintPreviewDialog(printer_, parent_);
    QVBoxLayout *mainLaoyout = new QVBoxLayout;
    createMenu(dialog);
    mainLaoyout->setMenuBar(menuBar);
    dialog->setLayout(mainLaoyout);

    void TextPrinter::createMenu(QDialog *dialog)
    {
    menuBar = new QMenuBar;
    fileMenu = new QMenu(tr("&File"),dialog);
    exitAction = fileMenu->addAction(tr("E&xit"));
    menuBar->addMenu(fileMenu);
    }
    @
    I do not get any results



  • Hi,

    menu bar are not intended to be used i Dialog, you should use in QMainWindow.
    However you can try modifying your code in

    @
    void TextPrinter::createMenu(QDialog *dialog)
    {
    menuBar = new QMenuBar (dialog);
    fileMenu = new QMenu(tr("&File"));
    exitAction = fileMenu->addAction(tr("E&xit"));
    menuBar->addMenu(fileMenu);
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.