Results 1 to 2 of 2

Thread: whether Qcanvas objects be added in QLayout

  1. #1
    Join Date
    Sep 2008
    Posts
    14
    Qt products
    Qt3
    Platforms
    Unix/X11

    Talking whether Qcanvas objects be added in QLayout

    hello friends

    this question would seem simple but i am needing help.

    i have to add a QCanvasEllipse to my QHBoxlayout.but it doesnt work
    QBoxlayout *toplayout=new QHBoxLayout(this);
    QCanvas *c=new QCanvas(100,100);
    QCanvasView *cv=new QCanvasView(c);

    QCanvasEllipse *elli=new QCanvasEllipse(50,50,.......,c);
    elli->setBrush(Qt::setCyan);
    toplayout->addWidget(cv);//can i do this.....

    a)how should i add the canvas object in my Qlayout...
    b)if not i need an ellipse to show the state of the object red n green...
    but making an ellipse using a QPainter object .i cannot add a Qpainter object in Qlayout

    Qpainter *p;
    toplayout->addWidget(p);//can i do this.....

    c)how do i add a nonrectangular widget in layout.

    sooner rply
    with regards
    Amrita

  2. #2
    Join Date
    Sep 2008
    Posts
    14
    Qt products
    Qt3
    Platforms
    Unix/X11

    Wink Re: whether Qcanvas objects be added in QLayout

    hello everyone

    i am not able to display the QCanvasEllipse in my Application window.here is the code,can some one find the error.

    /////////////...canvas.cpp

    #include <qapplication.h>
    #include <qcanvas.h>
    #include <qnamespace.h>
    #include <qlayout.h>
    #include"moc_canvas.cpp"
    #include<qlayout.h>
    int main( int argc, char **argv )
    {
    QApplication a(argc, argv);
    ApplicationWindow * mw = new ApplicationWindow(0,"busmonitor");
    mw->resize(1000,700);

    mw->show();
    a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );
    return a.exec();

    }

    ApplicationWindow::ApplicationWindow(QWidget *parent,const char* name)
    : QWidget(parent,name)
    {

    QBoxLayout *topLayout=new QVBoxLayout(this,10);
    QBoxLayout *row1 = new QHBoxLayout( topLayout );


    QCanvas *testCanvas = new QCanvas(this,"canvas");
    testCanvas->resize( 310, 100);
    QCanvasEllipse* ce=new QCanvasEllipse(40,40,0*16,360*16,testCanvas);
    ce->setX(180);
    ce->setY(75);
    ce->setBrush( QColor( "red" ) );
    QCanvasView canvasView(testCanvas, this,"canvasview");
    canvasView.setCanvas(testCanvas);
    QVBoxLayout vlay(&mainWidget);
    row1->addWidget(&canvasView);
    ce.show();

    }

    ApplicationWindow::~ApplicationWindow()
    {
    }


    ////////////////canvas.h..................


    #include <qmainwindow.h>


    class ApplicationWindow: public QWidget
    {
    Q_OBJECT

    public:
    ApplicationWindow(QWidget *parent,const char *name);
    ~ApplicationWindow();

    };

    ///////////..........

    this program compiles without error...n shows only a window....no ellipse

    just tryyyyyyyyy..

    Amrita

Similar Threads

  1. LibQxt
    By jpn in forum Qt-based Software
    Replies: 10
    Last Post: 9th October 2009, 22:20

Tags for this Thread

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.