我想在qt5中使用布局,但在Visual Studio 2015中布局不起作用?qt5布局在Visual Studio 2015中不起作用?
这里是我的代码:
layout.h代码
#ifndef LAYOUT_H
#define LAYOUT_H
#include <QtWidgets/QMainWindow>
#include "ui_layout.h"
class layout : public QMainWindow
{
Q_OBJECT
public:
layout(QWidget *parent = 0);
~layout();
private:
Ui::layoutClass ui;
};
#endif // LAYOUT_H
的main.cpp
#include "layout.h"
#include <QtWidgets/QApplication>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QHBoxLayout>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
layout w;
QHBoxLayout hb;
QPushButton b("button 0");
QPushButton b1("button 1");
hb.addWidget(&b);
hb.addWidget(&b1);
w.setLayout(&hb);
w.show();
return a.exec();
}
如何解决这个问题?
是什么布局? – eyllanesc
@eyllanesc QHBoxLayout和QVBoxLayout – lens
QVBoxLayout和QHBoxLayout没有show方法。 – eyllanesc