Results 1 to 20 of 24

Thread: setText in QToolButton ( qt4 )

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default setText in QToolButton ( qt4 )

    Hi,

    I have a QToolButton which is having a "QPixmap" loading from resourcefile ( MyResourceFile.qrc ) , with Qt3Support.

    After setting setting pixmap , am setting text in QToolButton uisng setText(). But in GUI it is not showing the TEXT , instead displays only the QOixmap.

    see the code..
    Qt Code:
    1. MyMainWindow::MyMainWindow()
    2. {
    3. --------
    4. ---------
    5.  
    6. QToolButton *btn= new QToolButton( QIcon(":Images/imageOne.png"), tr("Quit"),
    7. tr("Quit"), this, SLOT( close() ), myToolBar, "Quit"); //setting pixmap in QToolButton
    8.  
    9. btn->setText("My Text......"); //setting text in QToolButton
    10.  
    11.  
    12. ---------
    13. ---------
    14. -------
    15. }
    To copy to clipboard, switch view to plain text mode 


    Why this is not showing the text in QToolButton...??????
    please help me
    Last edited by jacek; 3rd July 2007 at 20:39. Reason: wrapped too long line

  2. #2
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setText in QToolButton ( qt4 )

    Try this :

    Qt Code:
    1. btn->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
    To copy to clipboard, switch view to plain text mode 

    By default, a QToolButton is in IconMode only, and won't display text

  3. #3
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: setText in QToolButton ( qt4 )

    It is not working...

  4. #4
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setText in QToolButton ( qt4 )

    Well then, post some more code, so I can reproduce the problem.

  5. #5
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: setText in QToolButton ( qt4 )

    I have given the full code in the first thread.
    let me explain...
    In my mainwindow-constructor i have created a QToolButton. that's it.

    You can try the same in your code.
    But the only difference is i am porting the code from Qt3.3.4 to Qt 4.2.2 using the QT3Support.

    please help me.
    thank you.

  6. #6
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setText in QToolButton ( qt4 )

    Ok, I'll try this in a small example once I'm at work (in 20 minutes) ;-)

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

    Default Re: setText in QToolButton ( qt4 )

    Could you provide a minimal and compilable example reproducing the problem? QToolButton::setToolButtonStyle() works just fine for me when using plain QToolButtons and QToolBar::setToolButtonStyle() does the trick when adding QActions to a QToolBar.
    J-P Nurmi

  8. #8
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setText in QToolButton ( qt4 )

    EDIT :
    Ooops sorry, forget what I wrote

    I'm almost finished with my sample.

  9. #9
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setText in QToolButton ( qt4 )

    By the way, if you don't set any pixmap in the button, does the string become visible ?

    I've made a little sample code, showing string only, and it works here...here it goes in attachment.
    Attached Files Attached Files

  10. #10
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: setText in QToolButton ( qt4 )

    Quote Originally Posted by guilugi View Post
    By the way, if you don't set any pixmap in the button, does the string become visible ?
    Thanks for your attempt.
    I can use either ICON or TEXT. But i need a button which can accomedate ICON & TEXT.

    N:B : Here am giving the full code. i am using Q3ToolBar and adding QToolButton to it. see this

    Qt Code:
    1. MyMainWindow::MyMainWindow()
    2. {
    3.  
    4. --------
    5. ---------
    6. Q3ToolBar *myToolBar = new Q3ToolBar( this );
    7.  
    8. QToolButton *btn= new QToolButton( QIcon(":Images/imageOne.png"), tr("Quit"),
    9. tr("Quit"), this, SLOT( close() ), myToolBar, "Quit"); //setting pixmap in QToolButton
    10.  
    11.  
    12.  
    13. btn->setText("My Text......"); //setting text in QToolButton
    14.  
    15.  
    16.  
    17.  
    18.  
    19. ---------
    20.  
    21. ---------
    22.  
    23. -------
    24.  
    25. }
    To copy to clipboard, switch view to plain text mode 

    Now can you identify....??
    Can i set any property so that i can accomedate both the icon , text. ...????



    thank u

  11. #11
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setText in QToolButton ( qt4 )

    Why can't you just use QToolBar, the native Qt4 class ?

Similar Threads

  1. QToolButton text alignment
    By Vladimir in forum Qt Programming
    Replies: 6
    Last Post: 2nd March 2007, 07:42
  2. QSqlRelationalDelegate Draw a clickable QToolButton
    By patrik08 in forum Qt Programming
    Replies: 5
    Last Post: 1st March 2007, 20:59
  3. Replies: 1
    Last Post: 26th November 2006, 09:32
  4. Problem with qtoolbutton
    By moowy in forum Qt Programming
    Replies: 1
    Last Post: 22nd September 2006, 13:30
  5. 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.