Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. GraphicsView -> Problem when maximizing window
Forum Updated to NodeBB v4.3 + New Features

GraphicsView -> Problem when maximizing window

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Harish Balakrishnan
    wrote on last edited by
    #1

    Hi, I am a newbie. I have set graphicsview(with a background image) as my central widget. When I Maximize my window , the background image in the graphics view keeps repeating and doesn't get maximized. I have tried almost all of the formatting options in the mainWindow.ui form editor.

    My objective is to have a background picture in my window and it should maximize along with the window (when the window is maximized) .

    Any sample code or guidance will be helpful.

    Thanks in Advance .

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KillGabio
      wrote on last edited by
      #2

      post your code so we can see what you are doing wrong

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Harish Balakrishnan
        wrote on last edited by
        #3

        Hi ,
        The following code is in my mainwindow.cpp file.
        I have just included a background-image to my graphicsview. When I build and run my project, the image in the graphicsview takes its own resolution, i.e., it doesn't fit exactly into my graphicsview. And when I maximize my mainwindow to fit the entire screen, the image in the graphicsview repeats ( my screen resolution is larger than the image resolution) .
        I am sure I am yet to learn some basic stuff but I just cant figure out what it is.

        <mainwindow.cpp>

        #include "mainwindow.h"
        #include "ui_mainwindow.h"

        MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
        {
        ui->setupUi(this);
        this->setCentralWidget(ui->graphicsView);
        ui->graphicsView->setStyleSheet("background-image: url(:/my/coffee-cup-01.jpg)");
        }

        MainWindow::~MainWindow()
        {
        delete ui;
        }

        1 Reply Last reply
        0
        • K Offline
          K Offline
          KillGabio
          wrote on last edited by
          #4

          Try using border image

          @ui->graphicsView->setStyleSheet("border-image: url(:/my/coffee-cup-01.jpg)”);@

          1 Reply Last reply
          0
          • K Offline
            K Offline
            KillGabio
            wrote on last edited by
            #5

            Try using border image

            @ui->graphicsView->setStyleSheet("border-image: url(:/my/coffee-cup-01.jpg)”);@

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Harish Balakrishnan
              wrote on last edited by
              #6

              Thanks KIIIGablo , it worked !! :-)

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved