Results 1 to 5 of 5

Thread: Where is my QPushButtons

  1. #1
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Where is my QPushButtons

    Qt Code:
    1. Test::Test(QWidget* parent):QDialog(parent)
    2. {
    3. setBackgroundRole(QPalette::Dark);
    4. setAutoFillBackground(true);
    5. setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    6.  
    7. //buttons settings
    8. settingButton=new QPushButton;
    9. settingButton->setText("settings");
    10. settingButton->adjustSize();
    11. oneStepButton=new QPushButton;
    12. oneStepButton->setText("one step");
    13. oneStepButton->adjustSize();
    14. runAllButton=new QPushButton;
    15. runAllButton->setText("run all");
    16. runAllButton->adjustSize();
    17. //place the buttons in a proper position
    18. settingButton->move(5, 5);
    19. oneStepButton->move(5 + settingButton->width() + 5, 5);
    20. runAllButton->move(15+settingButton->width()+oneStepButton->width(),5);
    21.  
    22. //plotter settings
    23. minX = 0.0;
    24. maxX = 10.0;
    25. numXTicks = 5;
    26.  
    27. minY = 0.0;
    28. maxY = 10.0;
    29. numYTicks = 5;
    30.  
    31. iniPoints();
    32. resize(600,400);
    33. }
    34.  
    35. void Test::refreshPixmap()
    36. {
    37. pixmap = QPixmap(size());
    38. pixmap.fill(this, 0, 0);
    39.  
    40. QPainter painter(&pixmap);
    41. painter.initFrom(this);
    42. drawGrid(&painter);
    43. drawPoints(&painter);
    44. update();
    45. }
    To copy to clipboard, switch view to plain text mode 

    In this program, I want to draw a coordinate and points in it. above the coordinate, I post three QPushButtons . Now my app can be executed, but the buttons can not turn up, leaving only the coordinate. I don't know why? Do you have any advise?

    Thanks!
    Last edited by HelloDan; 30th March 2009 at 05:42.

  2. #2
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Where is my QPushButtons

    settingButton->show();
    oneStepButton->show();
    runAllButton->show();


    I add these three lines in the constructor function. but the button post in the leftup corner, not in the dialog.

  3. #3
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Where is my QPushButtons

    make the dialog as the parent of the buttons

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Where is my QPushButtons

    maybe it would be better to use one of the layouts classes to manage controls position insted of using?
    Qt Code:
    1. ...
    2. settingButton->move(5, 5);
    3. oneStepButton->move(5 + settingButton->width() + 5, 5);
    4. runAllButton->move(15+settingButton->width()+oneStepButton->width(),5);
    5. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Where is my QPushButtons

    settingButton=new QPushButton(this);

    it works!

    thanks

Similar Threads

  1. QPushButton's text cut off on other computers
    By vonCZ in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2008, 19:41
  2. QPushButton's font is auto bold in WinCE
    By lovelypp in forum Qt Programming
    Replies: 0
    Last Post: 10th July 2008, 13:47
  3. Replies: 1
    Last Post: 1st November 2007, 07:25
  4. Mouse Over Event on QPushButtons
    By merry in forum Qt Programming
    Replies: 2
    Last Post: 6th August 2007, 13:23

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.