Results 1 to 6 of 6

Thread: Create a Toolbar on a Subclassed Textedit?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Create a Toolbar on a Subclassed Textedit?

    Here's an example illustrating what I meant:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char* argv[])
    4. {
    5. QApplication app(argc, argv);
    6. QMainWindow window;
    7. QMenu* fileMenu = window.menuBar()->addMenu("File");
    8. fileMenu->addAction("Quit", &window, SLOT(close()));
    9.  
    10. QTabWidget* tabWidget = new QTabWidget(&window);
    11. for (int i = 0; i < 3; ++i)
    12. {
    13. QMainWindow* wrapper = new QMainWindow(tabWidget);
    14. QTextEdit* textEdit = new QTextEdit(wrapper);
    15. QToolBar* toolBar = new QToolBar(wrapper);
    16. QMenu* menu = textEdit->createStandardContextMenu();
    17. toolBar->addActions(menu->actions());
    18. wrapper->addToolBar(Qt::TopToolBarArea, toolBar);
    19. wrapper->setCentralWidget(textEdit);
    20. tabWidget->addTab(wrapper, QString::number(i));
    21. }
    22.  
    23. window.setCentralWidget(tabWidget);
    24. window.show();
    25. return app.exec();
    26. }
    To copy to clipboard, switch view to plain text mode 
    Notice the usage of a wrapper QMainWindow inside QTabWidget.
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    c_07 (12th October 2007)

  3. #2
    Join Date
    Oct 2007
    Posts
    17
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Create a Toolbar on a Subclassed Textedit?

    OK, thanks, I get it now

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.