Results 1 to 2 of 2

Thread: unable to popup the QSlider on top of the pushButton

  1. #1
    Join Date
    Jun 2008
    Posts
    16
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question unable to popup the QSlider on top of the pushButton

    hi ,

    I am able to popup a slider on the click of a button, but it's not on top of the button...
    what should I do ..

    here is the code

    Qt Code:
    1. class MainWindow : public QMainWindow, public Ui::MainWindow
    2. {
    3. Q_OBJECT
    4. public:
    5. MainWindow( QWidget * parent = 0, Qt::WFlags f = 0 );
    6.  
    7.  
    8. QFrame *popup1;
    9.  
    10. private slots:
    11.  
    12. void pushButton_clicked();
    13. };
    14.  
    15. MainWindow::MainWindow( QWidget * parent, Qt::WFlags f)
    16. : QMainWindow(parent, f)
    17. {
    18. setupUi(this);
    19.  
    20. connect(pushButton, SIGNAL(clicked()), this, SLOT(pushButton_clicked()));
    21.  
    22. popup1 = new QFrame( this, Qt::Popup);
    23. popup1->resize(40,100);
    24.  
    25. QSlider *slid = new QSlider(Qt::Vertical, popup1);
    26. slid->resize(40,100);
    27. slid->show();
    28. }
    29.  
    30. void MainWindow:pushButton_clicked()
    31. {
    32. popup1->move(mapToGlobal(pushButton->geometry().bottomLeft()));
    33.  
    34. popup1->show();
    35.  
    36. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by marcel; 16th July 2008 at 10:29. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: unable to popup the QSlider on top of the pushButton

    You must add a simple layout to the frame, such as vertical or horizontal.
    Next, add the slider to the layout.
    It should work.

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

    qwakaw (16th July 2008)

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.