Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7914079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:59:47+00:00 2026-06-03T13:59:47+00:00

Is there any standard way to create drop-down menu from QLineEdit without QCompleter? For

  • 0

Is there any standard way to create drop-down menu from QLineEdit without QCompleter? For example, using QMenu or creating own class. Or there are any other existing widgets?

Or maybe I should use QAbstractItemModel for QCompleter? I’ve thought about it, but I don’t really understand this QAbstractItemModel. If you have experience about creating menu in this way, please also help me.

So I need a common type of drop-down menu: menu with lines, everyone of which includes icon (QPixmap) and text (QLabel) in itself. It’s like in Opera or Chrome browser in address input line, like the right part of Apple Spotlight etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:59:49+00:00Added an answer on June 3, 2026 at 1:59 pm

    It’s not possible with QMenu because it catch focus when showed and hides when loses focus. However, it’s possible to use QListWidget (or any other regular widget) for this. I developed some working example for the proof of concept. It’s default Qt Widget project with QMainWindow as main window. You need to add QLineEdit with name "lineEdit" into it and create slot for textChanged signa. Here’s the code:

    MainWindow.h:

    class MainWindow : public QMainWindow {
      Q_OBJECT  
    public:
      explicit MainWindow(QWidget *parent = 0);
      ~MainWindow();  
    private slots:
      void on_lineEdit_textChanged(const QString &arg1);
    private:
      Ui::MainWindow *ui;
      QListWidget* list;
    };
    

    MainWindow.cpp:

    #include "MainWindow.h"
    #include "ui_MainWindow.h"
    #include <QDebug>
    
    MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow),
      list(new QListWidget)
    {
      ui->setupUi(this);
      list->setWindowFlags(Qt::WindowFlags(
        Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
      list->setAttribute(Qt::WA_ShowWithoutActivating);
    }
    
    MainWindow::~MainWindow() {
      delete list;
      delete ui;
    }
    
    void MainWindow::on_lineEdit_textChanged(const QString &arg1) {
      if (ui->lineEdit->text().isEmpty()) {
        list->hide();
        return;
      }
      list->clear();
      list->addItem(ui->lineEdit->text());
      list->addItem(tr("Google: ") + ui->lineEdit->text());
      list->move(ui->lineEdit->mapToGlobal(QPoint(0, ui->lineEdit->height())));
      if (!list->isVisible()) list->show();
    }
    

    There are several problems: you should hide menu when line edit loses focus or user move window, you can’t set focus on the menu using down arrow button from line edit, etc. But I believe all these issues can be solved easily.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any standard way to route all Key events from the control A
Is there any easy way to change the color of the UITableViewCellAccessoryCheckmark from standard
Is there any way to create a function/callable object that inherits properties from another
Is there any standard way of implementing some sort of a write-through buffer for
Is there any way to throws an standard or custom exception with Apex method
Is there any way I can specify a standard or custom numeric format string
Is there any way to start foobar.js WSH-script in order that standard Task Manager
Is there any more or less standard way to specify a route that would
Is there any way of reliably allocating (reserving) hard disk space via standard Java
Is there any way to create a function with a real name that's determined

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.