Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QPrintPreviewDialog add QMenuBar

    General and Desktop
    2
    2
    1156
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      parcpaes last edited by

      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

      1 Reply Last reply Reply Quote 0
      • M
        mcosta last edited by

        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);
        }
        @

        Once your problem is solved don't forget to:

        • Mark the thread as SOLVED using the Topic Tool menu
        • Vote up the answer(s) that helped you to solve the issue

        You can embed images using (http://imgur.com/) or (http://postimage.org/)

        1 Reply Last reply Reply Quote 0
        • First post
          Last post