Results 1 to 16 of 16

Thread: problems creating toolbar...(do see the attachment)!

  1. #1
    Join Date
    Aug 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default problems creating toolbar...(do see the attachment)!

    Hi
    i am a beginner in qt and working on a GUI application based on QT 4.4.i am facing some problems with embedding a combobox in toobar.It is working with QT 3 but not with qt4.I am attaching a snap here so that i can explain better.If you can see this snap, i have three problems creating these kind of toolbar.
    1 there are tool buttons which are variable in size, and not arranged straight line (which is not a regular thing we do... right?) normally the buttons get placed in line with similar size.
    2.I am not able to place the Qcombobox with other tool buttons.they are either overlapping or not getting inserted.
    3.the lable below the toolbar,how I can set such a lable as QMainWindow in Qt4 doesnot have Setlable functionality.(which QT3 had...)

    Any kind of help is worth needed.....

    Thanks
    - Sumit
    Attached Images Attached Images

  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: problems creating toolbar...(do see the attachment)!

    Could you show us your code? I remember inserting a combobox into the toolbar in both Qt3 and Qt4 without any problems...

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problems creating toolbar...(do see the attachment)!

    Are you passing title in the constructor of QToolBar ??
    QToolBar::QToolBar ( const QString & title, QWidget * parent = 0 ) ???

    Also am not sure , but I guess the name of toolbar also depends on style,,, try running ur app with motif or some other style...

  4. #4
    Join Date
    Aug 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems creating toolbar...(do see the attachment)!

    Thanxs.....
    this is piece of my code ..... i am trying to create a toolabar with buttons (namedviewact is one of the buttons.)after that i will insert two comboboxes one right side of the button group and one below this set (buttton group and combobox..... in the same toolbar)....
    snything that I am missing?



    Qt Code:
    1. void HQApplication::CreateToolbars()
    2. {
    3. tools_toolbar = new QToolBar( "view", this);
    4. optionwidget = new QWidget(tools_toolbar);
    5. tools_toolbar->addAction(namedViewAct);
    6.  
    7. VisualStyleCombo = new QComboBox(optionwidget);
    8. VisualStyleCombo->setInsertPolicy(QComboBox::InsertAfterCurrent);
    9. VisualStyleCombo->addItem(*realisticIcon,tr("realistic"));
    10.  
    11. connect(VisualStyleCombo, SIGNAL(currentIndexChanged(int)),this, SLOT(VisualStyleChanged(int)));
    12.  
    13. QAction* qa = new QAction(VisualStyleCombo);
    14. qa->setVisible(true);
    15.  
    16. tools_toolbar->addWidget(optionwidget);///////// OR
    17. //tools_toolbar->insertWidget(namedViewAct,optionwidget);// i tried both
    18. this->addToolBar(tools_toolbar);
    19. }
    To copy to clipboard, switch view to plain text mode 

    Thanxs once again.........
    Last edited by jpn; 12th September 2008 at 17:56. Reason: missing [code] tags

  5. #5
    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: problems creating toolbar...(do see the attachment)!

    What is the optionwidget? You insert a combobox into it but without any layout. If you instead insert the combobox directly into the toolbar or apply a layout on "optionwidget" you should get the desired result.

  6. #6
    Join Date
    Aug 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems creating toolbar...(do see the attachment)!

    Hi guru
    i managed to solve the problem with inserting Qcombobox in a toolbar with the same code above....just it was matter of restructuring i.e. putting things in right place.
    now the big challenge before me is to get a view to toolbar in which I can insert tool buttons with variable QSize(for this i will attach another snap with this called variable_too_buttons.gif)
    any help in things will worth helpful....

    Thanxs for your help till now.................
    Attached Images Attached Images

  7. #7
    Join Date
    Aug 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems creating toolbar...(do see the attachment)!

    Quote Originally Posted by aamer4yu View Post
    Are you passing title in the constructor of QToolBar ??
    QToolBar::QToolBar ( const QString & title, QWidget * parent = 0 ) ???

    Also am not sure , but I guess the name of toolbar also depends on style,,, try running ur app with motif or some other style...




    hi
    i tried to use plastique and motif but .............. notthing worked can you please see my latest post..in that there is one attchment gif file.which explains my problem...
    still thanxs anyways.....

  8. #8
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problems creating toolbar...(do see the attachment)!

    Referring to the last gif, doesnt the name look like QLabel !! ???
    try adding QLabel in the QToolBar and see if u can get the desired effect.

    And if you are referring to the 'Realtime' text, you can use QToolBar::setToolButtonStyle(Qt::ToolButtonTextUnderIcon)

  9. #9
    Join Date
    Aug 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems creating toolbar...(do see the attachment)!

    no i am talking about the nevigation label...the realtime label is not a problem i have implemented that but the toolbar label is not getting inserted in right place.also the can you see the different tool button size/icon .... seems like this is a tool bar style but somehow i am unable to find this.......can someone help in creating such a toolbar..

    Thanx ....

  10. #10
    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: problems creating toolbar...(do see the attachment)!

    What does your "Navigation" bar do?

    You can get multiple rows of buttons if you insert a widget containing a layout of manually created buttons into the toolbar.

  11. #11
    Join Date
    Aug 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems creating toolbar...(do see the attachment)!

    thanx...
    i tried this (adding one widget with toolbuttons created inside it.) but my widget is not getting inserted(or visible?)on toolbar.QT says addwidget()-

    Adds the given widget to the toolbar as the toolbar's last item.
    If you add a QToolButton with this method, the tools bar's Qt::ToolButtonStyle will not be respected.
    Note: You should use QAction::setVisible() to change the visibility of the widget. Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.

    I tried this also but unsuccessfully... can you help in this regard.

  12. #12
    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: problems creating toolbar...(do see the attachment)!

    Can we see the code?

  13. #13
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems creating toolbar...(do see the attachment)!

    Hi, why not
    QAction * QToolBar::addWidget ( QWidget * widget ) I had used it to embed QComboBox in toolbar and it worked fine.
    This method is meant exactly for such cases!

    Adds the given widget to the toolbar as the toolbar's last item.
    If you add a QToolButton with this method, the tools bar's Qt::ToolButtonStyle will not be respected.
    This one is important:
    Note: You should use QAction::setVisible() to change the visibility of the widget. Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.
    So, insert your combobox directly without any layouts and additional widgets.
    and try with combobox created withoud any parant,
    addWidget () should deal with everything(reparenting, layout etc.) by itself, so simply do not disturb it.
    Qt Code:
    1. theQuickFinder = new ElQuickFinder();
    2. theFindToolBar->addWidget(theQuickFinder);
    To copy to clipboard, switch view to plain text mode 
    works fine in my app.

    You can read also about related
    QWidget * QToolBar::widgetForAction ( QAction * action ) constmethod.
    Last edited by mchara; 1st September 2008 at 09:16.
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

  14. #14
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems creating toolbar...(do see the attachment)!

    i've got mail that wysota has replied
    There is not much of your code here... Would you care to show us what ElQuickFinder contains?
    but i can't see the post - perhaps something went wrong...

    anyway...
    I can't post code of ElQuickFinder because it's part of commercial app with closed sources
    but first - code of ElQuickFinder is highly application specific so i think it won't help anyway,
    and second - i've placed emply class derived from combobox in toolbar and then i have started to writing quickfinder features and it worked well all the time with a number of different implementations from empty class to final implementation

    i'm using qt 4.3.5 so perhaps something changed in qt 4.4


    works fine also here (MdiWindowPrivate constructor in MdiWindow.cpp(GrEEn sources - see link in footnotes))
    Qt Code:
    1. // ToolBars creation.
    2. theFileToolBar = mainWindow->addToolBar(("File"));
    3. theFileToolBar->setIconSize(QSize(24,24));
    4. theFileToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
    5. theFileToolBar->addAction(theFileOpen);
    6. theFileToolBar->addAction(theFileSave);
    7.  
    8.  
    9. theFileToolBar->setObjectName("FileToolBar");
    10.  
    11. theViewToolBar = mainWindow->addToolBar(("View"));
    12. theViewToolBar->setObjectName("ViewToolBar");
    13. theViewZoomWidget = new QComboBox();
    14. theViewZoomWidget->addItem("10");
    15. theViewZoomWidget->addItem("25");
    16. theViewZoomWidget->addItem("50");
    17. theViewZoomWidget->addItem("75");
    18. theViewZoomWidget->addItem("100");
    19. theViewZoomWidget->addItem("200");
    20. theViewZoomWidget->addItem("300");
    21. theViewZoomWidget->addItem("400");
    22. theViewZoomWidget->addItem("FIT_TO_WINDOW");
    23. theViewZoomWidget->addItem("FIT_TO_WIDTH");
    24. theViewZoomWidget->addItem("FIT_TO_HEIGHT");
    25. theViewZoomWidget->setEditable(true);
    26. theViewZoomWidget->setEditText("");
    27. theViewZoomWidget->setValidator(new QIntValidator(theViewZoomWidget));
    28. theViewZoomWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
    29. theViewZoomWidget->setCompleter(NULL);
    30.  
    31. connect(theViewZoomWidget,
    32. SIGNAL(editTextChanged(const QString &)),
    33. mainWindow,
    34. SLOT(editTextChanged(const QString &)));
    35. theZoomLabel = new QLabel(("Zoom:"));
    36. theViewZoom = theViewToolBar->addWidget(theZoomLabel);
    37. theViewZoom = theViewToolBar->addWidget(theViewZoomWidget);
    38. theViewZoom = theViewToolBar->addWidget(new QLabel("%"));
    To copy to clipboard, switch view to plain text mode 
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

  15. #15
    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: problems creating toolbar...(do see the attachment)!

    You don't see my post because I deleted it as irrelevant.

  16. #16
    Join Date
    Aug 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems creating toolbar...(do see the attachment)!

    thank you everybody .... with the above suggestions and some modification the problem is almost solved now....(though some i am battling with some label related issues!!!! )..
    once again thanx for your help...

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.