Results 1 to 8 of 8

Thread: Click and drag for QMenuBar

  1. #1
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Click and drag for QMenuBar

    Hi guys,

    I want to make my application support click & drag option on QMenuBar because I'm using Qt::Window | Qt::CustomizeWindowHint flags.

    How can I add click & option for QMenuBar?

    PS
    See the attachment plz (screenshot & snippet)
    screenshot.11-05-2011 20.28.36.jpg
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Click and drag for QMenuBar

    You can turn it to a QToolBar.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Click and drag for QMenuBar

    Quote Originally Posted by high_flyer View Post
    You can turn it to a QToolBar.
    Thx, it seems that my question wasn't clear.

    I want to simulate the behavior of title bar on menu bar.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Click and drag for QMenuBar

    Why not just use QToolBar then?
    Last edited by high_flyer; 12th May 2011 at 13:08. Reason: typo
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Click and drag for QMenuBar

    Quote Originally Posted by high_flyer View Post
    Why not just use QTitleBar then?
    Dude there no class such like it?!!!!

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Click and drag for QMenuBar

    I meant QToolBar of course...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Click and drag for QMenuBar

    Quote Originally Posted by high_flyer View Post
    I meant QToolBar of course...
    OK, but QToolBar doesn't have suitable signals for simulating title bar behavior! I'm looking for something like this (it's just a pseudo):
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. setWindowFlags(Qt::Window | Qt::CustomizeWindowHint);
    6. ui->setupUi(this);
    7.  
    8. QHBoxLayout *lay = new QHBoxLayout();
    9. lay->setContentsMargins(0,0,0,0);
    10. lay->addWidget(ui->menuBar);
    11. lay->addWidget(ui->widget_buttons);
    12. ui->toolBar->setLayout(lay);
    13. connect(ui->menuBar, SIGNAL(clicked()), this, SLOT(setPoint()));
    14. connect(ui->menuBar, SIGNAL(mouseMove()), this, SLOT(setCoordinates()));
    15. }
    16. void MainWindow::setPoint()
    17. {
    18. point = cursor().pos();
    19. ui->statusBar->setWindowTitle(QString("X:%1 - Y:%2").arg(point.x()).arg(point.y()));
    20. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Click and drag for QMenuBar

    Oh now I see what you want...
    You want a custom title bar... I thought you want to be able to move your QMenuBar...

    There is no way around it - you will have to subclass what ever you use as your titlebar (QMenuBar in your case), and implement the functionality you need there.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 1
    Last Post: 7th May 2011, 20:24
  2. QTreeWidget: lost click after drag and drop
    By cresta in forum Qt Programming
    Replies: 12
    Last Post: 31st December 2010, 11:31
  3. QMenuBar hover/click clears QStatusBar in QMainWindow
    By killerwookie99 in forum Qt Programming
    Replies: 0
    Last Post: 16th November 2009, 15:09
  4. Replies: 6
    Last Post: 5th June 2009, 09:38
  5. Replies: 2
    Last Post: 11th January 2009, 23:24

Tags for this Thread

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.