Results 1 to 8 of 8

Thread: Toolbar in dockwidget

  1. #1
    Join Date
    Jun 2008
    Location
    Saint-Petersburg
    Posts
    50
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Toolbar in dockwidget

    Hello!
    How can I attach to dockwidget the toolbar?
    This code don't resolve this problem^
    Qt Code:
    1. ReliefGraphics::ReliefGraphics(QWidget *parent): toolBar(0), settings(0)
    2. {
    3. toolBar = new QToolBar(this, "toolBar");
    4. toolBar -> setObjectName(QString::fromUtf8("toolBar"));
    5. toolBar -> setToolButtonStyle(Qt::ToolButtonIconOnly);
    6. toolBar -> setAllowedAreas(Qt::LeftToolBarArea);
    7. toolBar -> setOrientation(Qt::Vertical);
    8. addIconToolbar();
    9.  
    10. settings = new PlotSettings();
    11. }
    12. ReliefGraphics::~ReliefGraphics()
    13. {
    14. if(toolBar) delete toolBar;
    15. if(settings) delete settings;
    16. }
    17. void ReliefGraphics::addIconToolbar()
    18. {
    19. QString text = "Save";
    20. toolBar -> addAction(QIcon("./Images/save.png"), text);
    21. text = "Repair";
    22. toolBar -> addAction(QIcon("./Images/repair.png"), text);
    23.  
    24. toolBar -> addSeparator();
    25. }
    To copy to clipboard, switch view to plain text mode 
    Where I wrong?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Toolbar in dockwidget

    QDockWidget cannot handle toolbars, only QMainWindow can. Add a QMainWindow inside the QDockWidget.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    AD (2nd October 2008)

  4. #3
    Join Date
    Jun 2008
    Location
    Saint-Petersburg
    Posts
    50
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Toolbar in dockwidget

    Thank you! How can I force this inner mainwindow in dockwidget? As so this mainwindow have been displayed above my mainwindow!

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Toolbar in dockwidget

    Quote Originally Posted by AD View Post
    How can I force this inner mainwindow in dockwidget?
    Just like any other widget, with QDockWidget::setWidget().

    As so this mainwindow have been displayed above my mainwindow!
    Sorry, what do you mean?
    J-P Nurmi

  6. #5
    Join Date
    Jun 2008
    Location
    Saint-Petersburg
    Posts
    50
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Toolbar in dockwidget

    Inner mainwindow displayed above main window of application!

  7. #6
    Join Date
    Jun 2008
    Location
    Saint-Petersburg
    Posts
    50
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Toolbar in dockwidget

    setWidget() don't help me!

  8. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Toolbar in dockwidget

    Try this:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char* argv[])
    4. {
    5. QApplication app(argc, argv);
    6. QMainWindow window;
    7.  
    8. QDockWidget* dock = new QDockWidget("Dock", &window);
    9. QMainWindow* inner = new QMainWindow(dock);
    10. inner->setWindowFlags(Qt::Widget); // <---------
    11. QToolBar* toolBar = new QToolBar(inner);
    12. inner->addToolBar(toolBar);
    13. dock->setWidget(inner);
    14.  
    15. window.addDockWidget(Qt::LeftDockWidgetArea, dock);
    16. window.setCentralWidget(new QLabel("Central", &window));
    17. window.show();
    18. return app.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 
    PS. Notice setWindowFlags().
    J-P Nurmi

  9. The following user says thank you to jpn for this useful post:

    AD (2nd October 2008)

  10. #8
    Join Date
    Jun 2008
    Location
    Saint-Petersburg
    Posts
    50
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Toolbar in dockwidget

    Thank You! ))))

    Worked!
    Last edited by AD; 2nd October 2008 at 15:01.

Similar Threads

  1. unable to hide combobox or spinbox in toolbar
    By Sandip in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2008, 11:52
  2. printing of dockWidget contents
    By user in forum Qt Programming
    Replies: 7
    Last Post: 18th May 2008, 23:07
  3. Toolbar and icon size
    By MrGarbage in forum Qt Programming
    Replies: 0
    Last Post: 8th January 2008, 21:27
  4. Create a Toolbar on a Subclassed Textedit?
    By c_07 in forum Qt Programming
    Replies: 5
    Last Post: 12th October 2007, 18:17
  5. QToolBar and DockWidget
    By baray98 in forum Qt Programming
    Replies: 3
    Last Post: 15th August 2007, 21:15

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.