Results 1 to 2 of 2

Thread: Qwt and context menu

  1. #1
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qwt and context menu

    I am trying to make a context menu, whenever the user right click on my plot.

    Qt Code:
    1. MyPlot::MyPlot( QWidget* parent) : QwtPlot(parent)
    2.  
    3. {
    4.  
    5. this->setContextMenuPolicy(Qt::CustomContextMenu);
    6. connect(this,SIGNAL(customContextMenuRequested(const QPoint & )),this,SLOT(popUpMenu(const QPoint &)));
    To copy to clipboard, switch view to plain text mode 

    and for sure
    Qt Code:
    1. void MyPlot::popUpMenu(const QPoint &pos)
    2. {
    3. qDebug()<<"meu aperto?"<<pos;
    4. QMenu menu;
    5. menu.addAction(a_print);
    6. menu.popup(pos);
    7. }
    To copy to clipboard, switch view to plain text mode 

    But nothing appear.
    I forgot something?

  2. #2
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt and context menu

    It seems that if I put
    Qt Code:
    1. menu.exec(QCursor::pos());
    To copy to clipboard, switch view to plain text mode 

    the menu shows up:
    But now, I wanna print the qwt plot.
    With the following code I can print, but the axis will not be present in the output although it is present in the plot.
    Help.
    Qt Code:
    1. void MyPlot::printOut()
    2. {
    3. QPrinter printer(QPrinter::HighResolution);
    4. printer.setOutputFileName(tr("diagrammasolare.pdf"));
    5. printer.setCreator("Solar Calc");
    6. printer.setOrientation(QPrinter::Landscape);
    7. printer.setOrientation(QPrinter::Portrait);
    8. QPrintDialog dialog(&printer);
    9. if ( dialog.exec() )
    10. {
    11. if ( printer.colorMode() == QPrinter::GrayScale )
    12. {
    13. int options = QwtPlotPrintFilter::PrintAll;
    14. options &= ~QwtPlotPrintFilter::PrintBackground;
    15. options |= QwtPlotPrintFilter::PrintFrameWithScales;
    16. filter.setOptions(options);
    17. }
    18.  
    19. print(printer, filter);
    20.  
    21.  
    22.  
    23. }
    24. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QWT right click window.. (Context Menu)
    By maveric in forum Qt Programming
    Replies: 4
    Last Post: 25th May 2008, 08:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.