Subject: CGAL users discussion list
List archive
- From: Mahmood Naderan <>
- To: CGAL discuss <>
- Subject: cannot create two QT window
- Date: Fri, 18 Apr 2008 21:54:28 -0700 (PDT)
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=lM/yg28SX/8blKfQZqCz9dvIB157b5uOtiCtM2agzTbRD2w96H+IXZJkqVCNuCYizdTbK5hF0KWOW9By6uGXkJDS5v8j8MHp+5wLIKYIhpn+uQX3ibx/nb16MUMZ3dSinQMj4otVadWWxFBPK7PMaI4QGNnjLEf5HHJe8pKNsyo=;
Hi,
How can I create two independent QT window? Here is what I wrote:
in the main():
QApplication app (argc, argv);
myProgram *w = new myProgram (....);
app.setMainWidget (w);
w->show();
return (app.exec());
In the constructor of myProgram class, I wrote:
// Create first window.
widget = new CGAL::Qt_widget(this);
widget->resize (INIT_WIDTH, INIT_HEIGHT);
widget->set_window (x_min, x_max, y_min, y_max);
connect(widget, SIGNAL(redraw_on_back()), this, SLOT(redraw_win()));
connect(widget, SIGNAL(s_mousePressEvent(QMouseEvent*)), this,
SLOT(mousePressEvent (QMouseEvent*)));
setCentralWidget(widget);
redraw_win();
// create second window
mWid = new CGAL::Qt_widget(this);
mWid->resize (INIT_WIDTH, INIT_HEIGHT);
mWid->set_window (x_min, x_max, y_min, y_max);
connect(mWid, SIGNAL(redraw_on_back()), this,
SLOT(redraw_winMahmood()));
connect(mWid, SIGNAL(s_keyPressEvent(QKeyEvent*)), this,
SLOT(keyPressEvent(QKeyEvent*)));
redraw_winMahmood();
functions for second window are:
void keyPressEvent(QKeyEvent *e)
{
mWid->redraw();
}
void redraw_winMahmood()
{ // based on CGAL manual
typedef CGAL::Cartesian<int> Rep;
typedef CGAL::Point_2<Rep> Point_2;
typedef CGAL::Segment_2<Rep> Segment;
mWid->resize(600, 600);
mWid->set_window(0, 600, 0, 600);
mWid->show();
mWid->lock();
*mWid << CGAL::BackgroundColor(CGAL::ORANGE) << CGAL::RED;
*mWid << Segment(Point_2(100,100), Point_2(400,400));
mWid->unlock();
}
The first window functions are ok; I mean if I only have the first window, it
works. The problem is when I add second window, after I press a key (because
there should be a key event in order to create second window), strangly the
first window closes!!!
What is wrong with it?
-------------------
Mahmood Naderan
http://ce.sharif.edu/~m_naderan
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
- cannot create two QT window, Mahmood Naderan, 04/19/2008
- Re: [cgal-discuss] cannot create two QT window, Sébastien Meunier, 04/19/2008
Archive powered by MHonArc 2.6.16.