Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24

Thread: Add QScrollArea to QDialog

  1. #21
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Add QScrollArea to QDialog

    Ok, now it is easy

    There are couple of ways to solve your problem.

    1. The easiest way would be to place a layout inside your MixerStrip class and then place all the widgets inside the layout instead of hardcoding all coordinates.
    2. Re-implement minimumSizeHint and maximumSizeHint. You could return the same value that you return in your sizeHint implementation.

  2. The following user says thank you to Rachol for this useful post:

    cpsmusic (26th June 2011)

  3. #22
    Join Date
    Jun 2010
    Posts
    30
    Thanks
    7

    Default Re: Add QScrollArea to QDialog

    Quote Originally Posted by Rachol View Post
    Ok, now it is easy

    There are couple of ways to solve your problem.

    1. The easiest way would be to place a layout inside your MixerStrip class and then place all the widgets inside the layout instead of hardcoding all coordinates.
    2. Re-implement minimumSizeHint and maximumSizeHint. You could return the same value that you return in your sizeHint implementation.
    I tried the second suggestion (see below) however the widgets are still spread out.

    Qt Code:
    1. #include "mixerstrip.h"
    2.  
    3. MixerStrip::MixerStrip(QWidget *parent) :
    4. QWidget(parent)
    5. {
    6. QSlider *volSlider = new QSlider(Qt::Vertical);
    7. volSlider->setMinimum(0);
    8. volSlider->setMaximum(100);
    9. QPalette pal = volSlider->palette();
    10. pal.setColor(volSlider->backgroundRole(), QColor(128, 128, 128));
    11. volSlider->setPalette(pal);
    12. volSlider->setAutoFillBackground(TRUE);
    13. volSlider->setGeometry(0,0,20,220);
    14. volSlider->setParent(this);
    15.  
    16. Meter *meter = new Meter;
    17. meter->setGeometry(20,0,50,220);
    18. meter->setParent(this);
    19.  
    20. QPushButton *muteButton = new QPushButton("M");
    21. QPushButton *soloButton = new QPushButton("S");
    22. muteButton->setCheckable(true);
    23. soloButton->setCheckable(true);
    24.  
    25. pal = muteButton->palette();
    26. pal.setColor(muteButton->backgroundRole(), QColor(128, 128, 128));
    27. muteButton->setPalette(pal);
    28. muteButton->setAutoFillBackground(TRUE);
    29. pal = soloButton->palette();
    30. pal.setColor(soloButton->backgroundRole(), QColor(128, 128, 128));
    31. soloButton->setPalette(pal);
    32. soloButton->setAutoFillBackground(TRUE);
    33.  
    34. muteButton->setGeometry(0,220,70,20);
    35. soloButton->setGeometry(0,240,70,20);
    36. muteButton->setParent(this);
    37. soloButton->setParent(this);
    38.  
    39. QSlider *panSlider = new QSlider(Qt::Horizontal);
    40. panSlider->setMinimum(-100);
    41. panSlider->setMaximum(100);
    42. panSlider->setValue(0);
    43. pal = panSlider->palette();
    44. pal.setColor(panSlider->backgroundRole(), QColor(128, 128, 128));
    45. panSlider->setPalette(pal);
    46. panSlider->setAutoFillBackground(TRUE);
    47. panSlider->setGeometry(0,260,70,20);
    48. panSlider->setParent(this);
    49.  
    50. QLineEdit *trackName = new QLineEdit();
    51. trackName->setAlignment(Qt::AlignCenter);
    52. trackName->setText("Track");
    53. trackName->setGeometry(0,280,70,20);
    54. trackName->setParent(this);
    55.  
    56. QObject::connect(volSlider, SIGNAL(valueChanged(int)), meter, SLOT(valueChanged(int)));
    57. volSlider->setValue(0);
    58.  
    59. setFixedSize(size());
    60. //setSizeConstraint ( QLayout::SetFixedSize );
    61. }
    62.  
    63. QSize MixerStrip::sizeHint() const
    64. {
    65. QSize size(70,300);
    66.  
    67. return size;
    68. }
    69.  
    70. QSize MixerStrip::minimumSizeHint() const
    71. {
    72.  
    73. QSize size(70,300);
    74.  
    75. return size;
    76. }
    77.  
    78. QSize MixerStrip::maximumSize()
    79. {
    80. QSize size(70,300);
    81.  
    82. return size;
    83. }
    To copy to clipboard, switch view to plain text mode 

  4. #23
    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: Add QScrollArea to QDialog

    Ok, I hope this should fix your problem for sure.

    When you implement size hints on your MixerStrip, then you don't need to set it to fixed size explicitly. Just remove the following statement at the end of MixerStrip Ctor, you should be done, worrying.
    Qt Code:
    1. //setFixedSize(size());
    To copy to clipboard, switch view to plain text mode 

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

    cpsmusic (26th June 2011)

  6. #24
    Join Date
    Jun 2010
    Posts
    30
    Thanks
    7

    Default Re: Add QScrollArea to QDialog

    Thanks, that last change solved the problem! Thanks very much, the people on this forum are very helpful.

Similar Threads

  1. Replies: 9
    Last Post: 25th March 2011, 21:22
  2. QDialog.exec() exiting without calling QDialog::accept()
    By doggrant in forum Qt Programming
    Replies: 3
    Last Post: 2nd February 2011, 11:35
  3. closing a Qdialog called from a Qdialog
    By OverTheOCean in forum Qt Programming
    Replies: 3
    Last Post: 28th September 2009, 08:02
  4. How to "lock" a new qdialog in another qdialog
    By donglebob in forum Qt Programming
    Replies: 7
    Last Post: 4th February 2009, 08:37
  5. Replies: 2
    Last Post: 10th March 2008, 20:16

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.