Results 1 to 10 of 10

Thread: Draw Line :confused:

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Draw Line :confused:

    Hi,
    I am new in QT. I do some small programes in QT.4.2.2. Now I try to
    create a small program, which one draw a line in a particular widget
    ( label ). I create a form in QT4.2.2 and place three labels in that form named as Label1,
    Label2 and Label3 and a pushButton.I need to run the program like this,
    when i click on the pushbutton, then a line draw in a label3. How can i
    do this?. I create two file like this, Please help me,
    Sabeesh C.S


    testdraw.h
    ************************
    Qt Code:
    1. #ifndef MYQTAPP_H
    2. #define MYQTAPP_H
    3. #include <QWidget>
    4. #include "ui_testdraw.h"
    5.  
    6. class myQtApp : public QMainWindow, private Ui::MainWindow
    7. {
    8. Q_OBJECT
    9. public:
    10. myQtApp(QWidget *parent = 0);
    11. public slots:
    12. void draw();
    13. protected:
    14. };
    15. #endif
    To copy to clipboard, switch view to plain text mode 

    --------------------------------------------
    testdraw.cpp
    *************************
    Qt Code:
    1. #include <QtGui>
    2. #include <qpainter.h>
    3. #include "testdraw.h"
    4. myQtApp::myQtApp(QWidget *parent)
    5. {
    6. setupUi(this);
    7. connect( pushButton, SIGNAL( clicked() ), this, SLOT( draw() ) );
    8. }
    9.  
    10.  
    11. void QLabel::paintEvent( QPaintEvent * ) {
    12. QPainter painter( this );
    13. painter.setPen(Qt::blue);
    14. painter.setFont(QFont("Arial", 40));
    15. QLineF line(10.0, 10.0, 10.0, 120.0);
    16. painter.drawLine(line);
    17. }
    18.  
    19.  
    20. void myQtApp::draw() {
    21. qDebug("Hello");
    22. }
    To copy to clipboard, switch view to plain text mode 
    ------------------------------------
    Last edited by jacek; 24th July 2007 at 01:24. Reason: missing [code] tags

Similar Threads

  1. QTextStream : Remove a Line?
    By kaydknight in forum Qt Programming
    Replies: 7
    Last Post: 31st January 2011, 18:15
  2. Draw a line in a Label
    By sabeesh in forum Qt Programming
    Replies: 4
    Last Post: 23rd July 2007, 13:27
  3. Draw rubberband line
    By Pang in forum Qt Programming
    Replies: 4
    Last Post: 13th July 2007, 23:09
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

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.