Results 1 to 19 of 19

Thread: how resize the Qwidget objects within a window

Hybrid View

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

    Default how resize the Qwidget objects within a window

    hai all,
    There is Qmainwindow which has 2 Qpushbuttons on the left side and Qlineedit onn the right side.I would like to get the two Qpushbuttons on the left hand side and QlineEdit resized when the QMainWindow is resized.I am novice in qt. i tried what i know but i failed. can someone help me

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how resize the Qwidget objects within a window

    Get yourself familiar with the concept of "layouts".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    vinayaka (23rd May 2011)

  4. #3
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how resize the Qwidget objects within a window

    hai wysota,
    i tried but failed. i tell u what it looks like .when the window was minimized the pushbutton was on the upperright hand side of the window. when it was maximized it was not on the upper right hand side of the window, on the other hand it got stick to the previous position. the right hand side was blank.

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how resize the Qwidget objects within a window

    Put your widgets into a layout or layouts. See Layout Management and Layout Examples

  6. The following user says thank you to ChrisW67 for this useful post:

    vinayaka (25th May 2011)

  7. #5
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how resize the Qwidget objects within a window

    hai,
    i have another problem. i have a base class A and 2 derived classes B,C. In A , there is a line Edit and 2 buttons. if we click 1st button int: entered in line edit of class A must be shown in B. if we click 2nd button it should be in C's window. what should I do?can some one tell me about multiple inheritance in detail(with simple example). ( i checked it but i didnt get it)

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how resize the Qwidget objects within a window

    What does your problem have to do with inheritance? Implement slots that will set values on objects and connect them to signals emitted when the buttons are clicked.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    vinayaka (25th May 2011)

  10. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how resize the Qwidget objects within a window

    If B and C inherit class A, the typical meaning of derived, then the question makes no sense. B is an A and C is an A. This has nothing to do with the number of windows displayed on screen or communication between them.

    I suspect you have three completely independent windows, A, B, and C, showing some widgets. You want events in A to trigger actions in B or C. You need to read about signals and slots

  11. The following user says thank you to ChrisW67 for this useful post:

    vinayaka (25th May 2011)

  12. #8
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how resize the Qwidget objects within a window

    yes , i have 3 independent windows.the integer entered in Ist window(A) must be shown in 2nd winB) when button 1 is clicked. when button 2 is clicked we must be in 3rd wiC) with int:.
    I went through some ex: but i didn't get it. Please help me(Can you teach me ,because i only started to learn cute Qt)

  13. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how resize the Qwidget objects within a window

    What exactly didn't you get in the examples?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. The following user says thank you to wysota for this useful post:

    vinayaka (25th May 2011)

  15. #10
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how resize the Qwidget objects within a window

    how we can inherit that intger when button is clicked?

  16. #11
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: how resize the Qwidget objects within a window

    connect button's clicked() / released() signal to a slot, and in the slot read the LineEdit contents, and populate it where ever it is needed

  17. The following user says thank you to Santosh Reddy for this useful post:

    vinayaka (25th May 2011)

  18. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how resize the Qwidget objects within a window

    Quote Originally Posted by vinayaka View Post
    how we can inherit that intger when button is clicked?
    Try writing some code, post it here and we'll help you fill in the blanks.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  19. #13
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how resize the Qwidget objects within a window

    Qt Code:
    1. #include "widget.h"
    2. #include "ui_widget.h"\
    3. #include"day25.h"
    4.  
    5. Widget::Widget(QWidget *parent) :
    6. QWidget(parent),
    7. ui(new Ui::Widget)
    8. {
    9. ui->setupUi(this);
    10. n=ui->lineEdit->text();
    11. }
    12.  
    13. Widget::~Widget()
    14. {
    15. delete ui;
    16. }
    17.  
    18. void Widget::on_pushButton_3_clicked()
    19. {
    20. day25 *k=new day25;
    21. k->show();
    22. this->hide();
    23.  
    24. }
    25.  
    26. ////////////////////////
    27. and in day25.cpp
    28. ///////////////////////////////
    29. #include "day25.h"
    30. #include "ui_day25.h"
    31. #include"widget.h"
    32.  
    33. day25::day25(Widget *parent) :
    34. Widget(parent),
    35. ui(new Ui::day25)
    36. {
    37.  
    38. ui->setupUi(this);
    39. ui->label_2->setText(n);
    40.  
    41.  
    42. }
    43.  
    44. day25::~day25()
    45. {
    46. delete ui;
    47. }
    To copy to clipboard, switch view to plain text mode 


    i tried, i entered a value and clicked the button but 2nd page(day25)is shown with previous one's object and no value is displayed

  20. #14
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: how resize the Qwidget objects within a window

    So how is that you are using the Classes A, B, and C?
    Looks like you have objects of all the three classes in your problem, is it so? If yes, please review your design again.

    Normally you would only need Objects (instance) of B and C (as Class A is already included in both B and C)

    One important thing to note is the only objects can send signals, classes cannot send. (I agree that "class" and "object" are used almost equally in this forum replies, but it looks like from your question, you have a problem to differentiate between them)

    You said Class A is base class, and Class B & Class C are derived (I assume derived from Class A). This is not multiple inheritance, this pain single class inheritance.

    When you say Class A has QLineEdit and QPushButtons, then it is implies that Class B and Class C already have a QLineEdit & QPushButtons in them.

    Please consider re-framing your question

    http://www.cplusplus.com/doc/tutorial/inheritance/

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.