Results 1 to 8 of 8

Thread: toolbar initial position

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default toolbar initial position

    I added a toolbar in a QMainWindow and wanted to have an initial position at Qt::BottomToolBarArea. I setAllowedAreas to that but this toolbar is always at the Qt::TopToolBarArea.

    Is there any other way to set inital position of the tool bar?

    Qt Code:
    1. QToolBar *toolBar = new QToolBar(this);
    2. toolBar->setAllowedAreas( Qt::BottomToolBarArea);
    3. setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    To copy to clipboard, switch view to plain text mode 


    baray98

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

    Default Re: toolbar initial position

    Try this:

    Qt Code:
    1. QToolBar *toolBar = new QToolBar(this);
    2. mainWindow->addToolBar(Qt::BottomToolBarArea, toolBar);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: toolbar initial position

    it is still on the top area of the windows after adding
    Qt Code:
    1. addToolBar(Qt::BottomToolBarArea,toolBar);
    To copy to clipboard, switch view to plain text mode 

    baray98

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

    Default Re: toolbar initial position

    Which version of Qt are you using?

  5. #5
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: toolbar initial position

    Qt 4.3.1 commercial version

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: toolbar initial position

    That's impossible.
    Have you added any actions to the toolbar?
    Try:
    Qt Code:
    1. toolbar->addAction("1");
    2. toolbar->addAction("2");
    3. toolbar->addAction("3");
    4. toolbar->addAction("4");
    To copy to clipboard, switch view to plain text mode 
    after adding it to the main window.

    With a default setup( you said you have qt commercial), the toolbar will be placed just above the status bar.

    If the toolbar has no actions, it is hard to notice it. Also, an empty menu bar looks just like an empty toolbar, so you might have got the wrong impression.

    Regards

  7. #7
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: toolbar initial position

    i have added some widgets no actions on this toolbar so it's pretty noticeable . It still staying at the topToolBarArea....

    baray98

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

    Default Re: toolbar initial position

    Please try the following code:
    Qt Code:
    1. #include <QApplication>
    2. #include <QMainWindow>
    3. #include <QToolBar>
    4.  
    5. int main(int argc, char **argv){
    6. QApplication app(argc, argv);
    7. QToolBar *tb = new QToolBar(&mw);
    8. tb->addAction("a1");
    9. tb->addAction("a2");
    10. mw.addToolBar(Qt::BottomToolBarArea, tb);
    11. mw.show();
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Initial Dialog Position
    By nleverin in forum Newbie
    Replies: 1
    Last Post: 15th July 2007, 10:19
  2. Initialise toolbar in a different area
    By georgie in forum Qt Programming
    Replies: 4
    Last Post: 4th May 2006, 03:49

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.