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. QDialog added to QGraphicsScene has no titlebar
Qt 6.11 is out! See what's new in the release blog

QDialog added to QGraphicsScene has no titlebar

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I'm trying to achieve the effect shown in the first image on this page: http://doc.qt.digia.com/qq/qq26-openglcanvas.html . However, my QDialog is not displaying its titlebar. Here is my relevant code:

    @
    void MainWindow(this is a QGraphicsView)::loginScreen()
    {
    QDialog* login = new QDialog(0, Qt::CustomizeWindowHint | Qt::WindowTitleHint);
    login->setWindowTitle("Connect to");
    login->setLayout(new VBoxLayout);
    login->layout()->addWidget(new QLineEdit("###.###.###.###"));
    login->layout()->addWidget(new QPushButton("Ok"));
    QGraphicsProxyWidget* proxy = scene()->addWidget(login);
    proxy->resize(size().width()/3, proxy->preferredSize().height());
    proxy->setPos(size().width()/2-proxy->size().width()/2, size().height()/2-proxy->size().height()/2);
    proxy->setFlag(QGraphicsItem::ItemIsMovable);
    proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
    }@

    Everything else displays fine, I just can't get the dialog's titlebar to show, nor can I move the dialog around. If it's not possible to fix the titlebar, I'd like to at least make the dialog movable.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      The title and the moving part are things that are drawn by the window manager, which is part of your operating system. Not Qt. Which explains why you don't see them.

      But please go through the examples and demos there are some in there that do very similar stuff, and the source is right there :)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DesiVideoGamer
        wrote on last edited by
        #3

        On your line:
        QGraphicsProxyWidget* proxy = scene()->addWidget(login);

        Change it to:

        QGraphicsProxyWidget* proxy = scene()->addWidget(login,Qt::Window);

        It will then draw it as a mini window with the proper decorations.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          That worked perfectly, thank you

          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