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. [Solved] Keeping a menubar for repeated use in QMainWindow::setMenuBar
Forum Updated to NodeBB v4.3 + New Features

[Solved] Keeping a menubar for repeated use in QMainWindow::setMenuBar

Scheduled Pinned Locked Moved Solved General and Desktop
setmenubarqmainwindow
22 Posts 4 Posters 7.8k 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.
  • Chris KawaC Offline
    Chris KawaC Offline
    Chris Kawa
    Lifetime Qt Champion
    wrote on last edited by
    #21

    @Harry123 said:

    This can only not work if there is a bug in the C++ compiler.

    As I said - it works here and now for you. But who's to say in a month or a year another person will for whatever reason create a local variable of type QMainWindow* and copy your pointer. The point is that because this method is not virtual a different method will be called depending on the type of pointer you access it through. That's a time bomb type of bug. It does not explode here and now for you but it will for someone else or future you.

    H 1 Reply Last reply
    0
    • Chris KawaC Chris Kawa

      @Harry123 said:

      This can only not work if there is a bug in the C++ compiler.

      As I said - it works here and now for you. But who's to say in a month or a year another person will for whatever reason create a local variable of type QMainWindow* and copy your pointer. The point is that because this method is not virtual a different method will be called depending on the type of pointer you access it through. That's a time bomb type of bug. It does not explode here and now for you but it will for someone else or future you.

      H Offline
      H Offline
      Harry123
      wrote on last edited by
      #22

      @Chris-Kawa
      Totally agree.

      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