Results 1 to 19 of 19

Thread: how resize the Qwidget objects within a window

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #15
    Join Date
    May 2011
    Posts
    120
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    33

    Default Re: how resize the Qwidget objects within a window

    i coded like this . if this is stupid forgive me okay
    Qt Code:
    1. //////////day25.cpp
    2. #include "day25.h"
    3. #include "ui_day25.h"
    4. #include "widget.h"
    5.  
    6.  
    7. day25::day25(Widget *parent) :
    8. Widget(parent),
    9. ui(new Ui::day25)
    10. {
    11.  
    12. ui->setupUi(this);
    13. //int num=100;
    14. QString qStr = QString::number(num);
    15. ui->label_2->setText(qStr);
    16.  
    17.  
    18. }
    19.  
    20. day25::~day25()
    21. {
    22. delete ui;
    23. }
    24.  
    25. ////////////widget.cpp
    26. #include "widget.h"
    27. #include "ui_widget.h"\
    28. #include "day25.h"
    29. //#include<QString>
    30.  
    31. Widget::Widget(QWidget *parent) :
    32. QWidget(parent),
    33. ui(new Ui::Widget)
    34. {
    35. ui->setupUi(this);
    36. //QString n;
    37. //n=ui->lineEdit->text();
    38. QString str;
    39. float num;
    40. str=ui->lineEdit->text();
    41. num=str.toInt();
    42.  
    43. }
    44.  
    45. Widget::~Widget()
    46. {
    47. delete ui;
    48. }
    49.  
    50. void Widget::on_pushButton_3_clicked()
    51. {
    52. day25 *k=new day25;
    53. k->show();
    54. this->hide();
    55.  
    56.  
    57. }
    58.  
    59. //////day25.h
    60. #ifndef DAY25_H
    61. #define DAY25_H
    62.  
    63. #include <QWidget>
    64. #include "widget.h"
    65.  
    66. namespace Ui {
    67. class day25;
    68. }
    69.  
    70. class day25 : public Widget
    71. {
    72. Q_OBJECT
    73.  
    74. public:
    75. explicit day25(Widget *parent = 0);
    76. ~day25();
    77.  
    78. private:
    79. Ui::day25 *ui;
    80. };
    81.  
    82. #endif // DAY25_H
    83.  
    84. /////widget.h
    85. #ifndef WIDGET_H
    86. #define WIDGET_H
    87.  
    88. #include <QWidget>
    89.  
    90. namespace Ui {
    91. class Widget;
    92. }
    93.  
    94. class Widget : public QWidget
    95. {
    96. Q_OBJECT
    97.  
    98. public:
    99. explicit Widget(QWidget *parent = 0);
    100. ~Widget();
    101.  
    102. private:
    103. Ui::Widget *ui;
    104.  
    105. private slots:
    106. void on_pushButton_3_clicked();
    107. };
    108.  
    109. #endif // WIDGET_H
    To copy to clipboard, switch view to plain text mode 
    error:num is not declared in this scope.
    if command is removed answer is always 100
    plz help meeeeeeeeee
    Last edited by vinayaka; 25th May 2011 at 11:31. Reason: spelling corrections

Similar Threads

  1. how to resize Qmainwindow with Qwidget ?
    By zeynepb.bil in forum Qt Programming
    Replies: 10
    Last Post: 28th September 2017, 23:48
  2. Replies: 3
    Last Post: 9th January 2010, 15:47
  3. Replies: 11
    Last Post: 25th February 2009, 17:35
  4. Resize QWidget in QMainWindow
    By aamer4yu in forum Qt Programming
    Replies: 1
    Last Post: 8th March 2007, 12:16
  5. Drawing on QWidget - strech & resize
    By kemp in forum Qt Programming
    Replies: 5
    Last Post: 22nd January 2007, 14:39

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.