我正试图在QT5中设计一个组合框.我正在使用QT Creator进行布局,并在启动时加载应用程序范围的样式表.
我与我的组合框有关的CSS如下:
QComboBox
{
color:white;
background-color: qlineargradient(x1:0, y1:0, x2:1,y2:1, stop: 1 rgba(228, 41, 81, 100), stop: 0 rgba(234, 107, 101, 100));
border-color: rgba(255,255,255,200);
border-width: 1px;
border-style: solid;
}
QComboBox QListView
{
border-style: none;
background-color: qlineargradient(x1:0, y1:0, x2:1,y2:0, stop: 1 rgba(228, 41, 81, 100), stop: 0 rgba(234, 107, 101, 100));
}
QComboBox::drop-down
{
width: 20px;
border: 1px;
border-color:white;
border-left-style:solid;
border-top-style: none;
border-bottom-style: none;
border-right-style: none;
}
QComboBox::down-arrow
{
image: url(:/ArrowImages/images/whitearrowdown16.png);
width: 16px;
height: 16px;
}
Run Code Online (Sandbox Code Playgroud)
但组合框中的文本颜色将重新标记为默认(黑色)颜色.下拉列表中的颜色为白色.边框颜色和样式都正常工作.组合框上的标签是否需要单独设置哪种子控制?还是我错过了别的什么?
谢谢.
编辑:
为清晰起见添加了屏幕截图
编辑2:看起来只有当组合框设置为不可编辑时才会出现(这对我的程序来说是正确的行为,因此对我没有帮助.)当组合框设置为可编辑时,它会正确地服从样式.我试过添加 …
我在使用boost asio创建一个非常简单的基于TCP的服务器 - 客户端连接时遇到了问题.当我从服务器上的客户端获得连接并进入处理async_read_some的方法时,我检查错误,并且总是收到错误1236,这会显示消息"网络连接已被本地系统中止".
我刚刚开始使用boost,所以我不太熟悉库的工作原理以及我可能做错了什么.我在下面提供了我的代码的简化版本:
/*Client connection code*/
ClientConnection::ClientConnection(boost::asio::io_service& io_service) : m_Socket(io_service)
{
}
ClientConnection::ClientConnectionPointer ClientConnection::Create(boost::asio::io_service& io_service)
{
return ClientConnection::ClientConnectionPointer(new ClientConnection(io_service));
}
void ClientConnection::handle_write(const boost::system::error_code& error, size_t bytes_transferred)
{
//once we've written our packet, just wait for more
m_Socket.async_read_some(boost::asio::buffer(m_IncomingBytesBuffer, MAX_BYTES_LENGTH),
boost::bind(&ClientConnection::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
void ClientConnection::handle_read(const boost::system::error_code& error, size_t bytes_transferred)
{
if(!error)
{
//deal with the data that comes in here
}
else
{
std::cout << "Error reading port data" << std::endl;
std::cout << error.message() << std::endl;
}
} …
Run Code Online (Sandbox Code Playgroud)