Results 1 to 13 of 13

Thread: Need help with QToolButton

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Posts
    11
    Thanks
    4
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Need help with QToolButton

    May be I dont understand something but how we can ti convert QToolButton to QToolBar?
    For expierence I wrote your code: cannot convert 'QToolButton*' to 'QToolBar*' in initialization.

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Need help with QToolButton

    oh sorry that was my mistake.

    I actually meant

    Qt Code:
    1. void MainWindow::addButton()
    2. {
    3. QToolButton* tb = new QToolButton(DockLeft, "");
    4. }
    To copy to clipboard, switch view to plain text mode 

    Sorry once again.

  3. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Need help with QToolButton

    Quote Originally Posted by jpn
    Store toolbar_but as a member variable. The toolbar_but in addButton() is different than in addToolBar(). It's just a dangling pointer in addButton().

    Quote Originally Posted by philipp1
    One button it creates.
    It's strange.

  4. #4
    Join Date
    Oct 2006
    Posts
    11
    Thanks
    4
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Need help with QToolButton

    Quote Originally Posted by munna View Post
    oh sorry that was my mistake.

    I actually meant

    Qt Code:
    1. void MainWindow::addButton()
    2. {
    3. QToolButton* tb = new QToolButton(DockLeft, "");
    4. }
    To copy to clipboard, switch view to plain text mode 

    Sorry once again.
    They is no such constructor QToolButton(DockLeft, ""); (I did't find it)

  5. #5
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Need help with QToolButton

    oh, I am sorry once again

    It should be

    Qt Code:
    1. void MainWindow::addButton()
    2. {
    3. QToolButton* tb = new QToolButton(this);
    4. }
    To copy to clipboard, switch view to plain text mode 

    Actually I got confused because of the QToolBar consstructor that your are using.

    The constructor that you are using is obsolete

    Qt Code:
    1. void MainWindow::addToolBar()
    2. {
    3. QToolBar* toolbar_but = new QToolBar("Open puctures",this, DockLeft , TRUE ,0);// this is obsolete
    4.  
    5. }
    To copy to clipboard, switch view to plain text mode 

    you should rather be using

    Qt Code:
    1. void MainWindow::addToolBar()
    2. {
    3. QToolBar* toolbar_but = new QToolBar(this,0);
    4. toolbar_but->setLabel("Open Pictures");
    5. }
    To copy to clipboard, switch view to plain text mode 

    or may be the other one according to your need.

Similar Threads

  1. Cannot hide QToolButton
    By munna in forum Qt Programming
    Replies: 3
    Last Post: 2nd October 2006, 09:41
  2. Problem with qtoolbutton
    By moowy in forum Qt Programming
    Replies: 1
    Last Post: 22nd September 2006, 13:30
  3. Need help with QToolButton
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 22nd April 2006, 14:55

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.