Results 1 to 2 of 2

Thread: Qtabwidget in Qdockwidget

  1. #1
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Qtabwidget in Qdockwidget

    Hello friends,

    I have problems in integrating a tabwidget with a tableview in a dockwigdet. My code is this:[HTML]QDockWidget *dockwindow = new QDockWidget(tr("Central"), this);
    dockwindow->minimumHeight();
    dockwindow->setAutoFillBackground(true);
    dockwindow->setAllowedAreas(Qt::RightDockWidgetArea);
    TabWidget1 = new QTabWidget(dockwindow);
    //--------------------------------------------------------------------------------------
    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    db.setDatabaseName("DRIVER={SQL Server};Server=######;Trusted_Connection=no;Databa se=######;Uid=####;Pwd=####;");
    db.setUserName("####");
    db.setPassword("####");
    db.setHostName("######");
    //--------------------------------------------------------------------------------------
    if (db.open()){
    QSqlQueryModel *model = new QSqlQueryModel;
    model->setQuery("SELECT * from Mitarbeiter");
    QTableView *TableSicht = new QTableView(TabWidget1);
    TabWidget1->addTab(TableSicht,QString(tr("SQL-Results")));
    QTextEdit *textedit=new QTextEdit();
    TabWidget1->addTab(textedit,QString(tr("MoDeSt-Edit")));
    TabWidget1->setTabShape(QTabWidget::Triangular);
    TabWidget1->setTabPosition(QTabWidget::South);
    //TabWidget1->addTab(TableSicht,QString("Zwei"));
    setCentralWidget(dockwindow);
    TableSicht->setModel(model);
    TableSicht->show();


    }else{
    QSqlError err = db.lastError ();
    QMessageBox::information(0, QObject::tr("Fehler"), err.text());
    }[/HTML]

    You can see the Dockwidget in the attached screenshot.

    Have you an idea what I do wrong???
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qtabwidget in Qdockwidget

    why are you putting the dock widget as central widget?
    Make sure you follow whats in here (which doesn't looks like from you code):
    http://doc.trolltech.com/4.2/qmainwi...g-dock-widgets
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 8
    Last Post: 4th February 2007, 00:42
  2. Adding QGroupBox to QTabWidget
    By mclark in forum Newbie
    Replies: 2
    Last Post: 17th January 2007, 16:27
  3. QTabWidget Placement and Display
    By mclark in forum Newbie
    Replies: 1
    Last Post: 16th January 2007, 20:34
  4. QDockWidget flicker
    By fellobo in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2006, 20:42
  5. Corner widget in QTabWidget doesn't show up
    By ePharaoh in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2006, 17:02

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.