Results 1 to 3 of 3

Thread: Output is there..but code doesnt look to be Perfect..!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Output is there..but code doesnt look to be Perfect..!

    Hi..
    I had tried to show a layout of buttons on View..it worked fine,but the return function ( retWidg() ) which i have specified in the main doesnt seems to be necessary..i mean to say is there any other solution by which i can avoid these statement and with it be more cleared in approach...

    Qt Code:
    1. #include "exclass.h"
    2.  
    3. #include <QApplication>
    4. #include <QGraphicsScene>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9.  
    10. exclass *w = new exclass;
    11.  
    12. QWidget *mainW = new QWidget;
    13.  
    14. mainW = w->retWidg();
    15. scene.addWidget(mainW);
    16. scene.addItem(w);
    17.  
    18. view.setScene(&scene);
    19.  
    20. view.show();
    21. return a.exec();
    22. }
    23.  
    24.  
    25. #ifndef EXCLASS_H
    26. #define EXCLASS_H
    27.  
    28. #include <QtGui/QWidget>
    29. #include <QGraphicsScene>
    30. #include <QGraphicsView>
    31. #include <QGraphicsItem>
    32. #include <QPainter>
    33. #include <QImage>
    34. #include <QPushButton>
    35. #include <QHBoxLayout>
    36. //#include <QString>
    37. //#include "ui_exclass.h"
    38.  
    39. class exclass :public QObject, public QGraphicsItem
    40. {
    41. Q_OBJECT
    42.  
    43. public:
    44. QPushButton *stopButton;
    45. QPushButton *playButton;
    46. QHBoxLayout *hboxLay;
    47.  
    48. QWidget *widg;
    49.  
    50. exclass(QGraphicsItem *parent = 0);
    51.  
    52. QWidget *retWidg();
    53.  
    54. QRectF boundingRect() const;
    55.  
    56. void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget);
    57.  
    58. };
    59.  
    60. #endif // EXCLASS_H
    61.  
    62.  
    63. #include "exclass.h"
    64.  
    65. exclass::exclass(QGraphicsItem *parent):QGraphicsItem(parent)
    66. {
    67.  
    68. hboxLay = new QHBoxLayout;
    69. playButton = new QPushButton;
    70. stopButton = new QPushButton;
    71. widg = new QWidget;
    72. hboxLay->addWidget(playButton);
    73. hboxLay->addWidget(stopButton);
    74. widg->setLayout(hboxLay);
    75.  
    76. }
    77.  
    78.  
    79. QWidget* exclass::retWidg()
    80. {
    81. return widg;
    82. }
    83.  
    84. QRectF exclass::boundingRect() const
    85. {
    86.  
    87. }
    88.  
    89. void exclass:paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget)
    90. {
    91.  
    92. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by marcel; 12th June 2008 at 17:53.

Similar Threads

  1. QProcess and capturing output
    By Aragorn in forum Qt Programming
    Replies: 7
    Last Post: 3rd May 2007, 16:57
  2. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  3. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  4. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 21:41

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.