PDA

View Full Version : Porting from Qt3 to Qt4



vermarajeev
21st June 2007, 07:27
Hi guys,
Seems to be silly question but I'm unable to achieve it.

I'm porting my application from Qt3 to Qt4 and is using Qt3 support classes for a while. The problem is I use Q3MainWindows, Q3DockWindow, QSplitter, Q3Frame as shown in code below. Now I want to hide/unhide the dockWindow. I do this by right clicking on toolBar. First I right click and the dockWindow is hidden then again I rightClick and click on 'routes' but the dockWindow doesnt appear. I dont know why.

Please dont suggest me to use QMainWindow, QDockWidget or so... I have already made lots of changes and cant revert back. Please help me to rectify this problem with the solution given

#include <Q3MainWindow>
#include <QSplitter>

class MainWindow : public Q3MainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent = 0);
~MainWindow();

private:
Q3DockWindow *treeDock;
QSplitter *s2;
Q3Frame *frame;

};


MainWindow::MainWindow(QWidget *parent)
: Q3MainWindow(parent)
{
treeDock = new Q3DockWindow( this, "routes" );
Q_CHECK_PTR( treeDock );
moveDockWindow( treeDock, Qt::Left );
treeDock->setHorizontallyStretchable( true );
treeDock->setVerticallyStretchable( true );
treeDock->setResizeEnabled( true );
treeDock->setOrientation( Qt::Vertical );
treeDock->setCaption( tr("Routes") );

s2 = new QSplitter( Qt::Vertical, this, "splitter" );
Q_CHECK_PTR( s2 );
setCentralWidget( s2 );
frame = new Q3Frame( s2 );
frame->setBackgroundColor( Qt::white );
frame->setAutoFillBackground( true );

Q3PopupMenu *file = new Q3PopupMenu;
Q_CHECK_PTR( file );

int openId = file->insertItem( tr("&Open..."), this, SLOT(fileOpen()),
Qt::CTRL+Qt::Key_O );

Q3PopupMenu *edit = new Q3PopupMenu;
Q_CHECK_PTR( edit );
int copyId = edit->insertItem( tr("&Copy"), this, SLOT(copy()), Qt::CTRL+Qt::Key_C );

menuBar()->insertItem( tr("&File"), file );
menuBar()->insertItem( tr("&Edit"), edit );
}


#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}

Thanks in advance

vermarajeev
22nd June 2007, 05:27
Can someone please help me out with this.

Thanks