Results 1 to 9 of 9

Thread: Sharing same QToolbar amongst multiple QMainWindows

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2013
    Location
    Colorado
    Posts
    45
    Thanks
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Sharing same QToolbar amongst multiple QMainWindows

    A function for creating common toolbars is exactly what I've been working on. You confirmed my suspicions.
    The code example at the top was trying to copy/clone the toolbar et al from the parent QMainWindow to the children.
    I know, bad form.
    I can't second guess why no QToolBar copy constructor is available, that would certainly make this whole exercise moot.

    Thanks for the help.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,369
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Sharing same QToolbar amongst multiple QMainWindows

    Quote Originally Posted by Henry Blue Heeler View Post
    I can't second guess why no QToolBar copy constructor is available, that would certainly make this whole exercise moot.
    For exactly the same reason why any QObject derived class cannot be copied -- QObject instances are identities, not values. For instance, if you make a number of signal/slot connections to the toolbar, should a copy have those connections as well or not?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2013
    Location
    Colorado
    Posts
    45
    Thanks
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Sharing same QToolbar amongst multiple QMainWindows

    I want the same slots for all the toolbars and now it's working great.
    Thanks again for the help!
    Something like
    Qt Code:
    1. void MainWindow::CreateToolBar( QMainWindow *parent )
    2. {
    3. QToolBar *tb = parent->addToolBar("test");
    4. QAction *actionPrint = tb->addAction( QObject::tr("Print Record"), this, SLOT(on_actionPrint_triggered()));
    5. actionPrint->setIcon(QPixmap(":/Images/printer.bmp"));
    6. actionPrint->setText(QObject::tr("Print Record"));
    7. actionPrint->setToolTip(QObject::tr("Print Record"));
    8. // ...
    9. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. [QtDesigner] Multiple rows of QToolBar
    By Malutek in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2013, 15:23
  2. how to set the QToolBar's actions to multiple rows
    By fly542 in forum Qt Programming
    Replies: 2
    Last Post: 25th July 2011, 03:00
  3. Replies: 4
    Last Post: 2nd July 2010, 21:16
  4. Replies: 4
    Last Post: 17th October 2009, 22:31
  5. How to change between QMainWindows???
    By webquinty in forum Newbie
    Replies: 3
    Last Post: 16th October 2009, 10:46

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
  •  
Qt is a trademark of The Qt Company.