Results 1 to 3 of 3

Thread: [qt3]invisible toolbar

  1. #1
    Join Date
    Feb 2006
    Location
    Piekary Slaskie, Poland
    Posts
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default [qt3]invisible toolbar

    I have a QMainWindow class object with menu and toolbar. When I compiled it everything was OK. But when I added a QVBoxLayout class object with rest stuff, I cannot see a toolbar. Only menu. What must I do to repair it? My constructor looks that:
    Qt Code:
    1. dialog::dialog(QWidget *parent, const char *name) : QMainWindow(parent, name)
    2. {
    3. setGeometry(200,200,500,300);
    4.  
    5. QMenuBar *menu = new QMenuBar(this);
    6. QPopupMenu *popup = new QPopupMenu(this);
    7. QToolBar *toolbar = new QToolBar();
    8. QToolButton *toolbutton = new QToolButton(QPixmap("fileopen"), "test","lszk",this,
    9. SLOT(wyjscie()),toolbar);
    10.  
    11. popup->insertItem("&ttt",this,SLOT(info()));
    12. menu->insertItem("&popup",popup);
    13. addToolBar(toolbar);
    14.  
    15. QListBox *lista = new QListBox(this);
    16. QPushButton *button = new QPushButton("ok",this);
    17. QPushButton *button2 = new QPushButton("anuluj",this);
    18. QVBoxLayout *pionowy = new QVBoxLayout(this);
    19. QHBoxLayout *poziomy = new QHBoxLayout(this);
    20.  
    21. for(int i=1;i<=10;++i)
    22. { QString string = QString("Element numer %1").arg(i);
    23. lista->insertItem(string); }
    24.  
    25. poziomy->addStretch();
    26. poziomy->addWidget(button);
    27. poziomy->addWidget(button2);
    28. pionowy->addWidget(lista);
    29. pionowy->addLayout(poziomy);
    30. //resize(200,150);
    31. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [qt3]invisible toolbar

    QMainWindow uses it's own layout, so you must use QMainWindow::setCentralWidget().

    Try this:
    Qt Code:
    1. dialog::dialog(QWidget *parent, const char *name) : QMainWindow(parent, name)
    2. {
    3. // ...
    4. QWidget *widget = new QWidget( this );
    5. QListBox *lista = new QListBox( widget );
    6. // ...
    7. QVBoxLayout *pionowy = new QVBoxLayout( widget );
    8. QHBoxLayout *poziomy = new QHBoxLayout( widget );
    9. // ...
    10. pionowy->addLayout( poziomy );
    11. setCentralWidget( widget );
    12. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to jacek for this useful post:

    lszk (26th February 2006)

  4. #3
    Join Date
    Feb 2006
    Location
    Piekary Slaskie, Poland
    Posts
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [qt3]invisible toolbar

    Thanks a lot. It works.

Similar Threads

  1. Toolbar in dockwidget
    By AD in forum Qt Programming
    Replies: 7
    Last Post: 2nd October 2008, 14:34
  2. unable to hide combobox or spinbox in toolbar
    By Sandip in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2008, 11:52
  3. Create a Toolbar on a Subclassed Textedit?
    By c_07 in forum Qt Programming
    Replies: 5
    Last Post: 12th October 2007, 18:17
  4. Adding a toolbar to a TableWidget
    By Walter in forum Qt Programming
    Replies: 2
    Last Post: 1st July 2007, 21:13
  5. 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.