Results 1 to 5 of 5

Thread: Adding a QLineEdit to a QToolBar

  1. #1
    Join Date
    Mar 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Adding a QLineEdit to a QToolBar

    Hi, I'm a relative newbie, have figured out quite a bit but am stuck on something that feels like it should be easy.

    I want to add a LineEdit Widget to the main toolbar
    It seems I can't do this in the designer :-(
    So I am trying to do it programmatically

    QLineEdit *txtIpAddress = new QLineEdit(ui.mainToolBar);
    QAction *action = ui.mainToolBar->addWidget(txtIpAddress);
    action->setVisible(true);

    nothing shows up on the toolbar though

    thanks, Scott

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Adding a QLineEdit to a QToolBar

    Your code is perfect and works for me. Check if it is "ui." (=dot) or "ui->". Depending of how you use the designer generated file in your program.

  3. #3
    Join Date
    Mar 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Adding a QLineEdit to a QToolBar

    I'm positive that "ui." is correct for my case (I'm doing the same in dozen's of other locations)
    Is there some setting in the properties window that could effect this ?

    Are you on windows (me) or linux ? (shouldn't matter)

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Adding a QLineEdit to a QToolBar

    ok, then it is strange. I am on linux but that shouldn't have any effect. Try to make an other simple project where you only add a line edit and a normal action to the toolbar. If it works there, you have an other error in your code (somewhere else).If it don't works, send the minimal example to the forum and if it works on other non windows machines and does also not works on other windows computers, then it must be a bug in windows...

  5. #5
    Join Date
    Mar 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Adding a QLineEdit to a QToolBar

    I did find my problem, I had the code snippet above in the wrong place and it wasn't getting called right away
    So it is correct, thanks !

Similar Threads

  1. QToolBar
    By Programm3r in forum Qt Programming
    Replies: 2
    Last Post: 22nd December 2009, 07:09
  2. Adding a QWidget to QToolbar
    By qtUser500 in forum Qt Tools
    Replies: 6
    Last Post: 16th October 2009, 18:16
  3. QToolBar
    By coderbob in forum Qt Programming
    Replies: 2
    Last Post: 18th December 2007, 04:27
  4. QToolBar
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 19:48
  5. Adding stretch to QToolBar in Qt4.3
    By drhex in forum Qt Programming
    Replies: 3
    Last Post: 3rd June 2007, 07:43

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.