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. QGraphicsView to cover small bottom region not whole region. Possible?
Qt 6.11 is out! See what's new in the release blog

QGraphicsView to cover small bottom region not whole region. Possible?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.0k Views 2 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
    houmingc
    wrote on last edited by
    #1

    Not all widget( video, tickers) are working on QGraphicsScene & QGraphicsView
    Thus, want QGraphicsView to cover only a small bottom label region.
    Any comments?
    Below is my code.

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    QWidget *window= new QWidget;
    window->setWindowTitle("My App");

    ml = new WidgetMarqueeLabel(this);
    ml->setTextFormat(Qt::RichText);
    ml->setAlignment(Qt::AlignBottom);
    ml->setText("this is a very long text, todays weathre is very hot");
    ml->setFont(QFont("Arial", 20,20));
    
    //label->setText("  ");
    QGridLayout *layout= new QGridLayout;
    video();
    
    layout->addWidget(videoWidget,0,0);
    layout->addWidget(videoWidget1,0,1);
    layout->addWidget(ml,1,0,1,2);
    
    //create a scene
    QGraphicsScene* scene = new QGraphicsScene();
    //create an item to put into the scene
    QGraphicsRectItem* rect= new QGraphicsRectItem();
    rect->setRect(0,0,100,100);
    //add the item to the scene
    scene->addItem(rect);
    
    //add a view->portion of view is viewable
    QGraphicsView* view = new QGraphicsView(scene);
    view->show();
    //window->setLayout(layout);
    //window->show();
    

    }

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by sierdzio
      #2

      QGraphicsView is just a widget, it can be used in layouts and combined with other widgets. So you should be perfectly able to place it only at the bottom of your UI. The problems right now seems to be that you are not placing view object in your layout - so it will not be positioned correctly.

      (Z(:^

      H 1 Reply Last reply
      0
      • sierdzioS sierdzio

        QGraphicsView is just a widget, it can be used in layouts and combined with other widgets. So you should be perfectly able to place it only at the bottom of your UI. The problems right now seems to be that you are not placing view object in your layout - so it will not be positioned correctly.

        H Offline
        H Offline
        houmingc
        wrote on last edited by
        #3

        Know how to create QGraphicsView in mainwindow.
        Could you please show QGraphicsView placed at the bottom of UI by code?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          layout->addWidget(view);

          Just make sure to put it in the right place in the grid. Or use a QVBoxLayout instead of the grid.

          (Z(:^

          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