Results 1 to 11 of 11

Thread: Are the QTabWidget and QTableView drawn based on the top-level window?

  1. #1
    Join Date
    Jul 2009
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Are the QTabWidget and QTableView drawn based on the top-level window?

    Here is my question:
    1. A transparent window(with Qt::Window Flag) has 2 sub-child-widget layouted by QVBoxLayout, and the buttom one has another sub-child-widget QTabWidget which then I put some QTableViews on. ----the structre
    2. Back to the top-level window, if I invoke blew:
    toplevelWindow->setAutoFillBackground(false); it'll show the window like:
    2.jpg(the first image) well transparency, but the Table View was not correct
    3. toplevelWindow->setAutoFillBackground(true); it'll show the windowas:
    1.jpg(the second image) the Background was painted black by system
    I just want the top-level window to be transparent but not child widget...
    PlateForm: Windows +qt 4.5.2
    Attached Images Attached Images
    • File Type: jpg 2.jpg (20.8 KB, 25 views)
    • File Type: jpg 1.jpg (21.0 KB, 23 views)
    Last edited by dotboy; 5th July 2009 at 05:44.

  2. #2
    Join Date
    Jul 2009
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Are the QTabWidget and QTableView drawn based on the top-level window?

    Is there anyone who can help me with this problem...thx...

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Are the QTabWidget and QTableView drawn based on the top-level window?

    Could you maybe explain again in other words what you mean? I don't see a question in your question
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jul 2009
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Are the QTabWidget and QTableView drawn based on the top-level window?

    Quote Originally Posted by wysota View Post
    Could you maybe explain again in other words what you mean? I don't see a question in your question
    ok, if I set the attribute of the top level widget with Qt::WA_TranslucentBackground but not set the autoFillBackground, then the child widget (like QTabWidget and QTableWidget) will not show as I want;
    And if I set them both (WA_TranslucentBackground and autoFillBackground), the child widget act as what I expect but the top level widget was not transparent...

    Do you know what I mean now? Thank you for your reply....

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Are the QTabWidget and QTableView drawn based on the top-level window?

    So you want a translucent parent with an opaque child, correct? I don't see why it shouldn't work, so we can try pinpointing the problem. Could you prepare a minimal compilable example reproducing the problem?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jul 2009
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Are the QTabWidget and QTableView drawn based on the top-level window?

    Did you see the jpgs that I uploaded before?
    I've already test the code for many times and the different between them is that if I set the transparency attribute of the top-level window. If it does then part of the child widgets(e.g through the QTabWidget's tab part we can see the desktop ) will show unexpected results.
    Hers is my code:
    Qt Code:
    1. DDialog::DDialog(QWidget* parent)
    2. :QWidget(parent, Qt::FramelessWindowHint | Qt::Dialog)
    3. {
    4. //this->setAutoFillBackground(true); //if it is set the top-level window was not transparent
    5. //if not, the child widget was not show correctly
    6. this->setAttribute(Qt::WA_TranslucentBackground);
    7. this->move(50, 50);
    8. this->resize(420, 430);
    9. this->Initialize();
    10. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void DDialog::Initialize()
    2. {
    3. QVBoxLayout* layout = new QVBoxLayout(this);
    4. this->setLayout(layout);
    5. layout->setMargin(0);
    6. layout->setSpacing(0);
    7. //TitleBar ZONE
    8. this->m_titleBar = new DTitleBar(this);
    9. layout->addWidget(m_titleBar);
    10.  
    11. this->m_mainWidget = new QWidget();
    12. layout->addWidget(m_mainWidget);
    13. m_mainWidget->setAutoFillBackground(true);
    14.  
    15. QStatusBar* statusBar = new QStatusBar();
    16. layout->addWidget(statusBar);
    17. statusBar->setAutoFillBackground(true);
    18. QVBoxLayout* centerLayout = new QVBoxLayout();
    19. this->m_mainWidget->setLayout(centerLayout);
    20.  
    21. //TabWidget ZONE
    22. this->m_tabWidget = new QTabWidget();
    23. this->m_tabWidget->setAttribute(Qt::WA_OpaquePaintEvent);
    24. centerLayout->addWidget(this->m_tabWidget);
    25. centerLayout->setMargin(10);
    26. this->m_tabWidget->setAutoFillBackground(true);
    27.  
    28. m_tabWidget->setGeometry(QRect(20, 20, 381, 361));
    29. this->m_tabWidget->setTabPosition(QTabWidget::North);
    30. this->m_tabWidget->setTabShape(QTabWidget::Rounded);
    31. this->m_tabWidget->setElideMode(Qt::ElideMiddle);
    32.  
    33. //TableView ZONE
    34. this->m_bmpTableHView = new QTableView();
    35. this->m_bmpTableIView = new QTableView();
    36. this->m_bmpTableHView->setAutoFillBackground(true);
    37. this->m_bmpTableIView->setAutoFillBackground(true);
    38. this->m_bmpTableHView->setGeometry(QRect(-10, -10, 391, 351));
    39. this->m_bmpTableHView->setFrameShadow(QFrame::Sunken);
    40. this->m_tabWidget->addTab(this->m_bmpTableHView, "BitMapHead");
    41. this->m_tabWidget->addTab(this->m_bmpTableIView, "BitMapInfoHead");
    42.  
    43. //QStandardItemModel ZONE
    44. this->m_tableHModel = new QStandardItemModel(4, 3, this);
    45. this->m_tableHModel->setHeaderData(0, Qt::Horizontal, tr("Name"));
    46. this->m_tableHModel->setHeaderData(1, Qt::Horizontal, tr("Bytes"));
    47. this->m_tableHModel->setHeaderData(2, Qt::Horizontal, tr("Value"));
    48. this->m_bmpTableHView->setModel(this->m_tableHModel);
    49.  
    50. this->m_tableIModel = new QStandardItemModel(4, 3, this);
    51. this->m_tableIModel->setHeaderData(0, Qt::Horizontal, tr("Name"));
    52. this->m_tableIModel->setHeaderData(1, Qt::Horizontal, tr("Bytes"));
    53. this->m_tableIModel->setHeaderData(2, Qt::Horizontal, tr("Value"));
    54. this->m_bmpTableIView->setModel(this->m_tableIModel);
    55.  
    56. //BUTTON ZONE
    57. QHBoxLayout* buttomLayout = new QHBoxLayout();
    58. centerLayout->addLayout(buttomLayout);
    59. this->m_OK = new QPushButton();
    60. this->m_OK->setGeometry(QRect(230, 390, 77, 25));
    61. this->m_OK->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    62. this->m_OK->setText(tr("OK"));
    63. buttomLayout->addWidget(m_OK, 0, Qt::AlignRight);
    64.  
    65. this->m_Cancel = new QPushButton();
    66. this->m_Cancel->setGeometry(QRect(310, 390, 77, 25));
    67. this->m_Cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    68. buttomLayout->addWidget(m_Cancel);
    69. this->m_Cancel->setText(tr("Cancel"));
    70. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Are the QTabWidget and QTableView drawn based on the top-level window?

    Please provide something compilable, I'd like to play a bit with the code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jul 2009
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Are the QTabWidget and QTableView drawn based on the top-level window?

    This is the project(compressed by winrar, I added ".zip" at the end)...
    Thx
    Attached Files Attached Files

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Are the QTabWidget and QTableView drawn based on the top-level window?

    Apart from weird mouse handling it works quite correct for me on Linux.

    Here is a shot:
    Attached Images Attached Images
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Jul 2009
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default

    No, didn't you see the tab is not showing correctly, and If you put a qtableView on the tabWidget, it'll also get itself shown correctly...
    And about mouse handling, I'm dealing with that yet...

    And you can compare the jpgs that I uploaded before, there is something different between the 2 QTableView. Around the Lable, one of them has color as the QPalette::Background, but the other one is looks like white.
    In the project you build, you can click the tab to see what will happen...
    Last edited by wysota; 6th July 2009 at 13:34.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Are the QTabWidget and QTableView drawn based on the top-level window?

    Look... apparently my interpretation of a "minimal compilable example reproducing the problem" and yours differ greatly. I'm not going to read through serveral hundred lines of code with texts I don't understand to find a solution to a problem I don't see. Please provide a minimal compilable example clearly reproducing the problem, at most 100 lines of code in a total of one class plus the main function. Currently you have provided a bunch of classes that intend to do something but it is far from being clear what they do, how they are activated, etc.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 7th June 2009, 10:47

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.