Results 1 to 9 of 9

Thread: Qt Designer how to insert a QWidget into a form item(widget, frame ,etc)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2014
    Posts
    11
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qt Designer how to insert a QWidget into a form item(widget, frame ,etc)

    Hi there, currently not looking to make a custom widget for this as it is only a layout class object. What I want to do is be able to create a pane/window or whatever i need so that I can place a QWidget class (that i created in code instead of on the form) inside so that I can adjust the positions etc on Qt Designer.

    So need two bits of information, one what item in Qt designer should i use to allow me to place a QWidget inside it?

    and two, how do i then insert my class object into this window/pane ?

    Layout class constructor listed below:

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6.  
    7. QPalette p(palette());
    8. p.setColor(QPalette::Background, Qt::lightGray);
    9. this->setAutoFillBackground(true);
    10. this->setPalette(p);
    11. this->resize(1000,500);
    12. this->setWindowTitle(QApplication::translate("toplevel", "CCTV"));
    13.  
    14. mplayer_wrapper *wrapper = new mplayer_wrapper(this);
    15. label = new QLabel(this);
    16. Timer = new QTimer(this);
    17.  
    18.  
    19. button1 = new QPushButton("Stop State");
    20. button2 = new QPushButton("Start Stream");
    21. button3 = new QPushButton("Time");
    22. vlayout = new QVBoxLayout();
    23.  
    24. vlayout->addWidget(wrapper);
    25. vlayout->addWidget(button1);
    26. vlayout->addWidget(button2);
    27. vlayout->addWidget(button3);
    28. vlayout->addWidget(label);
    29.  
    30. ui->centralWidget->setLayout(vlayout);
    31.  
    32. connect(button1, &QPushButton::clicked,wrapper,&mplayer_wrapper::stop_mplayer);
    33. connect(button2, &QPushButton::clicked,wrapper,&mplayer_wrapper::start_mplayer);
    34. //connect(button3, &QPushButton::clicked,this, &MainWindow::show_time);
    35. connect(Timer,&QTimer::timeout,this,&MainWindow::show_time);
    36.  
    37. //ui->widget->
    38.  
    39. Timer->start();
    40.  
    41. }
    To copy to clipboard, switch view to plain text mode 

    Specifically in regards to this code I want to insert mplayer_wrappers object wrapper. 90% of this code I want to do on the designer as it's becoming a nightmare when the layout is alot more complicated.
    Last edited by Ion; 18th September 2014 at 15:13.

Similar Threads

  1. Changing name of a Widget/Dialog (Designer form with Class)
    By alizadeh91 in forum Qt Programming
    Replies: 2
    Last Post: 15th March 2013, 20:46
  2. Replies: 0
    Last Post: 19th September 2011, 16:10
  3. Insert custom widget in the qt designer list box
    By eg3gg in forum Qt Programming
    Replies: 12
    Last Post: 6th September 2010, 09:06
  4. Replies: 0
    Last Post: 8th July 2009, 11:01
  5. Replies: 4
    Last Post: 6th February 2006, 14:30

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.