Почему у меня остались черные линии внизу и посередине виджета?C++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Anonymous
 Почему у меня остались черные линии внизу и посередине виджета?

Сообщение Anonymous »

Все мои виджеты немного смещаются вправо и вниз, а у первых двух виджетов посередине также есть черное пространство. Почему?
Заголовки:

Код: Выделить всё

#ifndef TOPAREACLASS_H
#define TOPAREACLASS_H

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

class topAreaClass : public QWidget
{
Q_OBJECT
public:
explicit topAreaClass(const QString& label,const QString& path, QWidget *parent = nullptr);

private:
QWidget* topArea;
QWidget* leftTopArea;

QHBoxLayout* topHBoxLayout;
QVBoxLayout* leftTopVBoxLayout;

QPixmap* m_pixLabelCurrency;
QLabel* m_currencyLabelPicture;
QLabel* m_nameOfCurrency;
QLineEdit* m_edit1;
};

#endif // TOPAREACLASS_H

Код: Выделить всё

#ifndef WIDGET_H
#define WIDGET_H

#include 
#include 
#include 
#include 
#include 
#include 
#include 

class Widget : public QWidget
{
Q_OBJECT

public:
Widget(QWidget *parent = nullptr);
~Widget();
private slots:

private:
QWidget* topArea;
QWidget* leftTopArea;

QHBoxLayout* topHBoxLayout;
QVBoxLayout* leftTopVBoxLayout;

QPixmap* m_pixLabelCurrency;
QLabel* m_currencyLabelPicture;
QLabel* m_nameOfCurrency;
QLineEdit* m_edit1;
};

#endif // WIDGET_H

cpp:

Код: Выделить всё

#include "widget.h"

#include 

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}

Код: Выделить всё

#include "topareaclass.h"

topAreaClass::topAreaClass(const QString& Label,const QString& path, QWidget *parent)
: QWidget{parent}
{
//topArea
topArea = new QWidget(this);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setFixedSize(500, 70);
setStyleSheet("background: grey;");

//leftTopArea
leftTopArea = new QWidget(topArea);
leftTopArea->setFixedSize(70, 70);
leftTopArea->setStyleSheet("background: grey;");
leftTopVBoxLayout = new QVBoxLayout(leftTopArea);
leftTopVBoxLayout->setContentsMargins(5,5,5,5);

//Flag
m_pixLabelCurrency = new QPixmap(path);
m_currencyLabelPicture = new QLabel();
m_currencyLabelPicture->setPixmap(m_pixLabelCurrency->scaled(60,30, Qt::KeepAspectRatio));
m_currencyLabelPicture->setAlignment(Qt::AlignCenter);

//Usd
m_nameOfCurrency = new QLabel(Label);
m_nameOfCurrency->setAlignment(Qt::AlignCenter);

leftTopVBoxLayout->addWidget(m_currencyLabelPicture);
leftTopVBoxLayout->addWidget(m_nameOfCurrency);

//edit1 (topRight)
m_edit1 = new QLineEdit("100000");
m_edit1->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_edit1->setStyleSheet("border: none;"
"font-size: 35px;"
"margin-right: 10px;");
m_edit1->setFixedHeight(70);

//QHBoxLayout

topHBoxLayout = new QHBoxLayout(this);
topHBoxLayout->setContentsMargins(0,0,0,0);

topHBoxLayout->addWidget(leftTopArea);
topHBoxLayout->addStretch();
topHBoxLayout->addWidget(m_edit1);
}

Код: Выделить всё

#include "widget.h"
#include "topareaclass.h"

Widget::Widget(QWidget *parent)
: QWidget(parent)
{
setFixedSize(500,700);
setStyleSheet("background: black;");
setWindowTitle("Currency Convertor");

QVBoxLayout* mainLayout = new QVBoxLayout(this);

topAreaClass* top1 = new topAreaClass("USD", ":/new/prefix1/build/usa.png");
topAreaClass* top2 = new topAreaClass("UAH", ":/new/prefix1/build/uah.png");

mainLayout->addWidget(top1);
mainLayout->addWidget(top2);
mainLayout->addStretch();
}

Widget::~Widget() {}
Изображение

Как это исправить, чтобы вокруг виджетов не оставалось места?


Подробнее здесь: https://stackoverflow.com/questions/786 ... -my-widget
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Почему у меня остались черные линии внизу и посередине виджета?
    Anonymous » » в форуме C++
    0 Ответы
    17 Просмотры
    Последнее сообщение Anonymous
  • Почему у меня остались черные линии внизу и посередине виджета?
    Anonymous » » в форуме C++
    0 Ответы
    15 Просмотры
    Последнее сообщение Anonymous
  • Клавиатура iOS появляется посередине, а затем внизу.
    Anonymous » » в форуме IOS
    0 Ответы
    10 Просмотры
    Последнее сообщение Anonymous
  • Создание линии с кругом посередине
    Anonymous » » в форуме CSS
    0 Ответы
    19 Просмотры
    Последнее сообщение Anonymous
  • Opengl, черные линии между плитками
    Anonymous » » в форуме C++
    0 Ответы
    12 Просмотры
    Последнее сообщение Anonymous

Вернуться в «C++»